Codota Logo
SessionImplementor.flush
Code IndexAdd Codota to your IDE (free)

How to use
flush
method
in
org.hibernate.engine.spi.SessionImplementor

Best Java code snippets using org.hibernate.engine.spi.SessionImplementor.flush (Showing top 20 results out of 315)

  • Common ways to obtain SessionImplementor
private void myMethod () {
SessionImplementor s =
  • Codota IconEntityManager entityManager;entityManager.unwrap(SessionImplementor.class)
  • Codota IconFlushEntityEvent flushEntityEvent;flushEntityEvent.getSession()
  • Codota IconLazyInitializer lazyInitializer;lazyInitializer.getSession()
  • Smart code suggestions by Codota
}
origin: hibernate/hibernate-orm

@Override
public void flush() {
  delegate.flush();
}
origin: hibernate/hibernate-orm

session.flush();
origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-3930" )
public void testEagerFetchBidirectionalOneToOneWithDirectFetching() {
  inTransaction( session -> {
    EntityA a = new EntityA( 1L, new EntityB( 2L ) );
    
    session.persist( a );
    session.flush();
    session.clear();
    // Use atomic integer because we need something mutable
    final AtomicInteger queryExecutionCount = new AtomicInteger();
    
    session.getEventListenerManager().addListener( new StatisticalLoggingSessionEventListener() {
      @Override
      public void jdbcExecuteStatementStart() {
        super.jdbcExecuteStatementStart();
        queryExecutionCount.getAndIncrement();
      }
    } );
    
    session.find( EntityA.class, 1L );
    
    assertEquals(
        "Join fetching inverse one-to-one didn't use the object already present in the result set!",
        1,
        queryExecutionCount.get()
    );
  } );
}
origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-3930" )
public void testFetchBidirectionalOneToOneWithCircularJoinFetch() {
  inTransaction( session -> {
    EntityA a = new EntityA( 1L, new EntityB( 2L ) );
    session.persist( a );
    session.flush();
    session.clear();
    // Use atomic integer because we need something mutable
    final AtomicInteger queryExecutionCount = new AtomicInteger();
    session.getEventListenerManager().addListener( new StatisticalLoggingSessionEventListener() {
      @Override
      public void jdbcExecuteStatementStart() {
        super.jdbcExecuteStatementStart();
        queryExecutionCount.getAndIncrement();
      }
    } );
    session.createQuery(
        "from EntityA a join fetch a.b b join fetch b.a"
    ).list();
    assertEquals(
        "Join fetching inverse one-to-one didn't use the object already present in the result set!",
        1,
        queryExecutionCount.get()
    );
  } );
}
origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-3930" )
public void testFetchBidirectionalOneToOneWithOneJoinFetch() {
  inTransaction( session -> {
    EntityA a = new EntityA( 1L, new EntityB( 2L ) );
    session.persist( a );
    session.flush();
    session.clear();
    // Use atomic integer because we need something mutable
    final AtomicInteger queryExecutionCount = new AtomicInteger();
    session.getEventListenerManager().addListener( new StatisticalLoggingSessionEventListener() {
      @Override
      public void jdbcExecuteStatementStart() {
        super.jdbcExecuteStatementStart();
        queryExecutionCount.getAndIncrement();
      }
    } );
    session.createQuery(
        "from EntityA a join fetch a.b"
    ).list();
    assertEquals(
        "Join fetching inverse one-to-one didn't use the object already present in the result set!",
        1,
        queryExecutionCount.get()
    );
  } );
}
origin: hibernate/hibernate-orm

nonStrictReadWriteVersionedCacheableItem1.getTags().remove("ORM");
s1.flush();
s1.refresh( readWriteCacheableItem1 );
s1.refresh( readWriteVersionedCacheableItem1 );
origin: hibernate/hibernate-orm

@Test
public void testInsertWithRollback() {
  sessionFactory().getCache().evictEntityRegions();
  sessionFactory().getStatistics().clear();
  inTransaction(
      sessionFactory,
      s -> {
        CacheableItem item = new CacheableItem( "data" );
        s.save( item );
        s.flush();
        s.getTransaction().markRollbackOnly();
      }
  );
  assertFalse( sessionFactory().getCache().containsEntity( CacheableItem.class, 1L ) );
}
origin: hibernate/hibernate-orm

@Test
public void testInsertThenUpdateThenRollback() {
  sessionFactory().getCache().evictEntityRegions();
  sessionFactory().getStatistics().clear();
  inTransaction(
      sessionFactory,
      s -> {
        CacheableItem item = new CacheableItem( "data" );
        s.save( item );
        s.flush();
        item.setName( "new data" );
        s.getTransaction().markRollbackOnly();
      }
  );
  assertFalse( sessionFactory().getCache().containsEntity( CacheableItem.class, 1L ) );
}
origin: hibernate/hibernate-orm

@Test
public void testInsertWithClear() {
  sessionFactory().getCache().evictEntityRegions();
  sessionFactory().getStatistics().clear();
  inTransaction(
      sessionFactory,
      s -> {
        CacheableItem item = new CacheableItem( "data" );
        s.save( item );
        s.flush();
        s.clear();
      }
  );
  assertTrue( sessionFactory().getCache().containsEntity( CacheableItem.class, 1L ) );
  inTransaction(
      sessionFactory,
      s -> s.createQuery( "delete CacheableItem" ).executeUpdate()
  );
}
origin: hibernate/hibernate-orm

@Test
public void testInsertWithRefresh() {
  sessionFactory().getCache().evictEntityRegions();
  sessionFactory().getStatistics().clear();
  inTransaction(
      sessionFactory,
      s -> {
        CacheableItem item = new CacheableItem( "data" );
        s.save( item );
        s.flush();
        s.refresh( item );
      }
  );
  assertTrue( sessionFactory().getCache().containsEntity( CacheableItem.class, 1L ) );
  inTransaction(
      sessionFactory,
      s -> s.createQuery( "delete CacheableItem" ).executeUpdate()
  );
}
origin: hibernate/hibernate-orm

@Test
public void testInsertThenUpdate() {
  sessionFactory().getCache().evictEntityRegions();
  sessionFactory().getStatistics().clear();
  inTransaction(
      sessionFactory,
      s -> {
        CacheableItem item = new CacheableItem( "data" );
        s.save( item );
        s.flush();
        item.setName( "new data" );
      }
  );
  assertTrue( sessionFactory().getCache().containsEntity( CacheableItem.class, 1L ) );
  inTransaction(
      sessionFactory,
      s -> s.createQuery( "delete CacheableItem" ).executeUpdate()
  );
}
origin: hibernate/hibernate-orm

@Test
public void testInsertWithClearThenRollback() {
  sessionFactory().getCache().evictEntityRegions();
  sessionFactory().getStatistics().clear();
  inTransaction(
      sessionFactory,
      s -> {
        CacheableItem item = new CacheableItem( "data" );
        s.save( item );
        s.flush();
        s.clear();
        item = s.get( CacheableItem.class, item.getId() );
        s.getTransaction().markRollbackOnly();
      }
  );
  assertFalse( sessionFactory().getCache().containsEntity( CacheableItem.class, 1L ) );
  inTransaction(
      sessionFactory,
      s -> {
        final CacheableItem item = s.get( CacheableItem.class, 1L );
        assertNull( "it should be null", item );
      }
  );
}
origin: hibernate/hibernate-orm

CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.flush();
s.refresh( item );
s.getTransaction().markRollbackOnly();
origin: org.hibernate.orm/hibernate-core

@Override
public void flush() {
  delegate.flush();
}
origin: org.jboss.seam/jboss-seam

public void flush()
{
 ((SessionImplementor) delegate).flush();   
}
origin: riotfamily/riot

public void flush() {
  session.flush();
}
origin: babyfish-ct/babyfish

@Override
protected Ref<V> onVisionallyRead(K key, QueuedOperationType nullOrOperationType) {
  SessionImplementor session = this.session;
  if (session != null && this.hasQueuedOrphans()) {
    session.flush();
  }
  return this.basePersistence.visionallyRead(key);
}
origin: babyfish-ct/babyfish

@Override
protected Ref<V> onVisionallyRead(K key, QueuedOperationType nullOrOperationType) {
  SessionImplementor session = this.session;
  if (session != null && this.hasQueuedOrphans()) {
    session.flush();
  }
  return this.basePersistence.visionallyRead(key);
}

origin: babyfish-ct/babyfish

@Override
protected int onGetVisionalSize() {
  SessionImplementor session = this.session;
  CollectionEntry ce = 
      session
      .getPersistenceContext()
      .getCollectionEntry(this.<PersistentMANavigableMap<K, V>>getRootWrapper());
  CollectionPersister persister = ce.getLoadedPersister();
  if (!persister.isInverse()) {
    return -1;
  }
  if (session != null && this.hasQueuedOrphans()) {
    session.flush();
  }
  return persister.getSize(ce.getLoadedKey(), session);
}
origin: org.hibernate/com.springsource.org.hibernate.core

protected Boolean readElementExistence(Object element) {
  if (!initialized) {
    throwLazyInitializationExceptionIfNotConnected();
    CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
    CollectionPersister persister = entry.getLoadedPersister();
    if ( persister.isExtraLazy() ) {
      if ( hasQueuedOperations() ) {
        session.flush();
      }
      return persister.elementExists( entry.getLoadedKey(), element, session );
    }
  }
  read();
  return null;
  
}

org.hibernate.engine.spiSessionImplementorflush

Popular methods of SessionImplementor

  • getFactory
    Get the creating SessionFactoryImplementor
  • getTransactionCoordinator
  • connection
  • getPersistenceContext
    Get the persistence context for this session
  • getLoadQueryInfluencers
    Get the load query influencers associated with this session.
  • isTransactionInProgress
    Does this Session have an active Hibernate transaction or is there a JTA transaction in progress?
  • getEntityPersister
    Get the EntityPersister for any instance
  • getJdbcCoordinator
  • isClosed
    Determine whether the session is closed. Provided separately from #isOpen() as this method does not
  • getTenantIdentifier
    Match te method on org.hibernate.Session and org.hibernate.StatelessSession
  • generateEntityKey
  • getContextEntityIdentifier
  • generateEntityKey,
  • getContextEntityIdentifier,
  • isOpen,
  • bestGuessEntityName,
  • getFlushMode,
  • getSessionFactory,
  • guessEntityName,
  • immediateLoad,
  • initializeCollection

Popular in Java

  • Making http requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • onCreateOptionsMenu (Activity)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • JPanel (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now