Package org.hibernate.impl

Examples of org.hibernate.impl.SessionImpl$CoordinatingEntityNameResolver


    //return SessionFactoryUtils.getSession(sessionFactory, true);
    return sessionFactory.getCurrentSession();
  }
 
  private EntityStatus getStatus(Object model){
    SessionImpl simpl = (SessionImpl)getSession();   
    EntityEntry entry = simpl.getPersistenceContext().getEntry(model);
    if(entry != null){
      //Persistent Object
      logger.debug("current {} is one Entity with entry in PersistenceContext.", model);
      if (entry.getStatus() != Status.DELETED) {
        logger.debug("EntityStatus: {}", EntityStatus.PERSISTENT );
View Full Code Here


    super.tearDown();
  }

  public void testHiLoAlgorithm() {
    SessionImpl session = (SessionImpl) sessionFactory.openSession();
    session.beginTransaction();

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // initially sequence should be uninitialized
    assertEquals( 0L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // historically the hilo generators skipped the initial block of values;
    //     so the first generated id value is maxlo + 1, here be 4
    Long generatedValue = (Long) generator.generate( session, null );
    assertEquals( 4L, generatedValue.longValue() );
    // which should also perform the first read on the sequence which should set it to its "start with" value (1)
    assertEquals( 1L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 5L, generatedValue.longValue() );
    assertEquals( 1L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 6L, generatedValue.longValue() );
    assertEquals( 1L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 7L, generatedValue.longValue() );
    // unlike the newer strategies, the db value will not get update here.  It gets updated on the next invocation
    //   after a clock over
    assertEquals( 1L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 8L, generatedValue.longValue() );
    // this should force an increment in the sequence value
    assertEquals( 2L, extractSequenceValue( session ) );

    session.getTransaction().commit();
    session.close();
  }
View Full Code Here

    super.tearDown();
  }

  public void testHiLoAlgorithm() {
    SessionImpl session = (SessionImpl) sessionFactory.openSession();
    session.beginTransaction();

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // initially sequence should be uninitialized
    assertEquals( 0L, extractInDatabaseValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Long generatedValue = (Long) generator.generate( session, null );
    assertEquals( 1L, generatedValue.longValue() );
    assertEquals( 1L, extractInDatabaseValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 2L, generatedValue.longValue() );
    assertEquals( 1L, extractInDatabaseValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 3L, generatedValue.longValue() );
    assertEquals( 1L, extractInDatabaseValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 4L, generatedValue.longValue() );
    assertEquals( 2L, extractInDatabaseValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 5L, generatedValue.longValue() );
    assertEquals( 2L, extractInDatabaseValue( session ) );

    session.getTransaction().commit();
    session.close();
  }
View Full Code Here

    super.tearDown();
  }

  public void testHiLoAlgorithm() {
    SessionImpl session = (SessionImpl) sessionFactory.openSession();
    session.beginTransaction();

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // initially sequence should be uninitialized
    assertEquals( 0L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // historically the hilo generators skipped the initial block of values;
    //     so the first generated id value is maxlo + 1, here be 4
    Long generatedValue = (Long) generator.generate( session, null );
    assertEquals( 1L, generatedValue.longValue() );
    // which should also perform the first read on the sequence which should set it to its "start with" value (1)
    assertEquals( 1L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 2L, generatedValue.longValue() );
    assertEquals( 2L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 3L, generatedValue.longValue() );
    assertEquals( 3L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 4L, generatedValue.longValue() );
    assertEquals( 4L, extractSequenceValue( session ) );

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    generatedValue = (Long) generator.generate( session, null );
    assertEquals( 5L, generatedValue.longValue() );
    assertEquals( 5L, extractSequenceValue( session ) );

    session.getTransaction().commit();
    session.close();
  }
View Full Code Here

        .setLong( "last", lastContainerId.longValue() )
        .list();
    Container container = ( Container ) all.get( 0 );
    s.delete( container );
    // force a snapshot retrieval of the proxied container
    SessionImpl sImpl = ( SessionImpl ) s;
    sImpl.getPersistenceContext().getDatabaseSnapshot(
        lastContainerId,
            sImpl.getFactory().getEntityPersister( Container.class.getName() )
    );
    assertFalse( Hibernate.isInitialized( proxy ) );
    t.commit();

//    int iterations = 50;
View Full Code Here

    s = openSession();
    s.beginTransaction();
    s.replicate(baz, ReplicationMode.OVERWRITE);
    // HHH-2378
    SessionImpl x = (SessionImpl)s;
    EntityEntry entry = x.getPersistenceContext().getEntry( baz );
    assertNull(entry.getVersion());
    // ~~~~~~~
    s.getTransaction().commit();
    s.close();
View Full Code Here

            <property name="hibernate.ejb.interceptor" value="ariba.ui.meta.hibernate.Interceptor"/>
     */

    protected <T> T getIfAlreadyLoaded(java.lang.Class<T> tClass, Object primaryKey)
    {
        SessionImpl session = (SessionImpl)getSession();
        ClassMetadata classMeta = session.getSessionFactory().getClassMetadata(tClass);
        String entityName = classMeta.getEntityName();
        EntityPersister persister = session.getFactory().getEntityPersister(entityName);
        EntityKey entityKey = new EntityKey((Serializable)primaryKey, persister, EntityMode.POJO);

        return (T)((SessionImpl)getSession()).getPersistenceContext().getEntity(entityKey);
        //  return find(tClass, primaryKey);
        // return (T)getSession().get(tClass, (Serializable)primaryKey);
View Full Code Here

    s.close();
    s = openSession();
    s.replicate(baz, ReplicationMode.OVERWRITE);
   
    // HHH-2378
    SessionImpl x = (SessionImpl)s;
    EntityEntry entry = x.getPersistenceContext().getEntry( baz );
    assertNull(entry.getVersion());
   
    s.flush();
    s.connection().commit();
    s.close();
View Full Code Here

        .setLong( "last", lastContainerId.longValue() )
        .list();
    Container container = ( Container ) all.get( 0 );
    s.delete( container );
    // force a snapshot retrieval of the proxied container
    SessionImpl sImpl = ( SessionImpl ) s;
    sImpl.getPersistenceContext().getDatabaseSnapshot(
        lastContainerId,
            sImpl.getFactory().getEntityPersister( Container.class.getName() )
    );
    assertFalse( Hibernate.isInitialized( proxy ) );
    t.commit();

//    int iterations = 50;
View Full Code Here

        .setLong( "last", lastContainerId.longValue() )
        .list();
    Container container = ( Container ) all.get( 0 );
    s.delete( container );
    // force a snapshot retrieval of the proxied container
    SessionImpl sImpl = ( SessionImpl ) s;
    sImpl.getPersistenceContext().getDatabaseSnapshot(
        lastContainerId,
            sImpl.getFactory().getEntityPersister( Container.class.getName() )
    );
    assertFalse( Hibernate.isInitialized( proxy ) );
    t.commit();

//    int iterations = 50;
View Full Code Here

TOP

Related Classes of org.hibernate.impl.SessionImpl$CoordinatingEntityNameResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.