Java Code Examples for org.hibernate.persister.collection.CollectionPersister#insertRows()
The following examples show how to use
org.hibernate.persister.collection.CollectionPersister#insertRows() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollectionUpdateAction.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void execute() throws HibernateException { final Serializable id = getKey(); final SharedSessionContractImplementor session = getSession(); final CollectionPersister persister = getPersister(); final PersistentCollection collection = getCollection(); final boolean affectedByFilters = persister.isAffectedByEnabledFilters( session ); preUpdate(); if ( !collection.wasInitialized() ) { if ( !collection.hasQueuedOperations() ) { throw new AssertionFailure( "no queued adds" ); } //do nothing - we only need to notify the cache... } else if ( !affectedByFilters && collection.empty() ) { if ( !emptySnapshot ) { persister.remove( id, session ); } } else if ( collection.needsRecreate( persister ) ) { if ( affectedByFilters ) { throw new HibernateException( "cannot recreate collection while filter is enabled: " + MessageHelper.collectionInfoString( persister, collection, id, session ) ); } if ( !emptySnapshot ) { persister.remove( id, session ); } persister.recreate( collection, id, session ); } else { persister.deleteRows( collection, id, session ); persister.updateRows( collection, id, session ); persister.insertRows( collection, id, session ); } getSession().getPersistenceContext().getCollectionEntry( collection ).afterAction( collection ); evict(); postUpdate(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatistics().updateCollection( getPersister().getRole() ); } }
Example 2
Source File: CollectionUpdateAction.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void execute() throws HibernateException { final Serializable id = getKey(); final SessionImplementor session = getSession(); final CollectionPersister persister = getPersister(); final PersistentCollection collection = getCollection(); boolean affectedByFilters = persister.isAffectedByEnabledFilters(session); if ( !collection.wasInitialized() ) { if ( !collection.hasQueuedOperations() ) throw new AssertionFailure( "no queued adds" ); //do nothing - we only need to notify the cache... } else if ( !affectedByFilters && collection.empty() ) { if ( !emptySnapshot ) persister.remove( id, session ); } else if ( collection.needsRecreate(persister) ) { if (affectedByFilters) { throw new HibernateException( "cannot recreate collection while filter is enabled: " + MessageHelper.collectionInfoString( persister, id, persister.getFactory() ) ); } if ( !emptySnapshot ) persister.remove( id, session ); persister.recreate( collection, id, session ); } else { persister.deleteRows( collection, id, session ); persister.updateRows( collection, id, session ); persister.insertRows( collection, id, session ); } getSession().getPersistenceContext() .getCollectionEntry(collection) .afterAction(collection); evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor(). updateCollection( getPersister().getRole() ); } }