/** * Get the current snapshot from the session */ protected final Serializable getSnapshot() { return session.getPersistenceContext().getSnapshot(this); }
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException { if (session==null) { return UNKNOWN; } else { return session.getPersistenceContext() .getOwnerId( entityName, propertyName, target, mergeMap ); } }
/** * Get the current snapshot from the session */ protected final Serializable getSnapshot() { return session.getPersistenceContext().getSnapshot(this); }
public Object getForInsert(Object target, SessionImplementor session) throws HibernateException { if (session==null) { return BackrefPropertyAccessor.UNKNOWN; } else { return session.getPersistenceContext().getIndexInOwner(collectionRole, target); } }
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException { if (session==null) { return BackrefPropertyAccessor.UNKNOWN; } else { return session.getPersistenceContext() .getIndexInOwner(entityName, propertyName, target, mergeMap); } }
/** * Is this collection in a state that would allow us to * "queue" additions? */ private boolean isQueueAdditionEnabled() { return !initialized && isConnectedToSession() && session.getPersistenceContext().isInverseCollection(this); } /**
Object processEntity(Object value, EntityType entityType) throws HibernateException { if (value!=null) { getSession().getPersistenceContext().reassociateIfUninitializedProxy(value); // if it is an initialized proxy, let cascade // handle it later on } return null; }
/** * Is this instance persistent or detached? * If <tt>assumed</tt> is non-null, don't hit the database to make the * determination, instead assume that value; the client code must be * prepared to "recover" in the case that this assumed result is incorrect. */ public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session) throws HibernateException { if (entity instanceof HibernateProxy) return true; if ( session.getPersistenceContext().isEntryFor(entity) ) return true; return !isTransient(entityName, entity, assumed, session); }
private void endCollectionLoad( final Object resultSetId, final SessionImplementor session, final CollectionPersister collectionPersister ) { //this is a query and we are loading multiple instances of the same collection role session.getPersistenceContext().getCollectionLoadContext() .endLoadingCollections( collectionPersister, resultSetId, session ); }
protected final Serializable getId() { if ( id instanceof DelayedPostInsertIdentifier ) { return session.getPersistenceContext().getEntry( instance ).getId(); } return id; }
/** * Is this the "inverse" end of a bidirectional association? */ private boolean isInverseCollection() { CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this); return ce != null && ce.getLoadedPersister().isInverse(); }
protected final Serializable getKey() { finalKey = key; if ( key instanceof DelayedPostInsertIdentifier ) { // need to look it up from the persistence-context finalKey = session.getPersistenceContext().getEntry( collection.getOwner() ).getId(); if ( finalKey == key ) { // we may be screwed here since the collection action is about to execute // and we do not know the final owner key value } } return finalKey; }
private Session openTemporarySessionForLoading(PersistentCollection coll) { final SessionFactory sf = _sessionFactory; final Session session = sf.openSession(); PersistenceContext persistenceContext = ((SessionImplementor) session).getPersistenceContext(); persistenceContext.setDefaultReadOnly(true); session.setFlushMode(FlushMode.MANUAL); persistenceContext.addUninitializedDetachedCollection( ((SessionFactoryImplementor) _sessionFactory).getCollectionPersister(coll.getRole()), coll ); return session; }
private Session openTemporarySessionForLoading(PersistentCollection coll) { final SessionFactory sf = _sessionFactory; final Session session = sf.openSession(); PersistenceContext persistenceContext = ((SessionImplementor) session).getPersistenceContext(); persistenceContext.setDefaultReadOnly(true); session.setFlushMode(FlushMode.MANUAL); persistenceContext.addUninitializedDetachedCollection( ((SessionFactoryImplementor) _sessionFactory).getCollectionPersister(coll.getRole()), coll ); return session; }
public boolean isNullifiable(boolean earlyInsert, SessionImplementor session) { return getStatus() == Status.SAVING || ( earlyInsert ? !isExistsInDatabase() : session.getPersistenceContext().getNullifiableEntityKeys() .contains( new EntityKey( getId(), getPersister(), entityMode ) ) ); }
public boolean isNull(Object owner, SessionImplementor session) { if ( propertyName != null ) { EntityPersister ownerPersister = session.getFactory().getEntityPersister(entityName); Serializable id = session.getEntityIdentifier(owner); EntityKey entityKey = new EntityKey( id, ownerPersister, session.getEntityMode() ); return session.getPersistenceContext().isPropertyNull( entityKey, getPropertyName() ); } else { return false; } }
/** * Return the underlying persistent object in the given <tt>Session</tt>, or null, * do not initialize the proxy */ public final Object getImplementation(SessionImplementor s) throws HibernateException { return s.getPersistenceContext().getEntity( new EntityKey( getIdentifier(), s.getFactory().getEntityPersister( getEntityName() ), s.getEntityMode() ) ); }
/** * Return the underlying persistent object in the given <tt>Session</tt>, or null, * do not initialize the proxy */ public final Object getImplementation(SessionImplementor s) throws HibernateException { final EntityKey entityKey = new EntityKey( getIdentifier(), s.getFactory().getEntityPersister( getEntityName() ), s.getEntityMode() ); return s.getPersistenceContext().getEntity( entityKey ); }
private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session) throws HibernateException { final PersistenceContext persistenceContext = session.getPersistenceContext(); CollectionEntry entry = persistenceContext.getCollectionEntry(coll); log.debug( "Found collection with unloaded owner: " + MessageHelper.collectionInfoString( entry.getLoadedPersister(), entry.getLoadedKey(), session.getFactory() ) ); entry.setCurrentPersister( entry.getLoadedPersister() ); entry.setCurrentKey( entry.getLoadedKey() ); prepareCollectionForUpdate( coll, entry, session.getEntityMode(), session.getFactory() ); }
public void execute() throws HibernateException { final PersistentCollection collection = getCollection(); getPersister().recreate( collection, getKey(), getSession() ); getSession().getPersistenceContext() .getCollectionEntry(collection) .afterAction(collection); evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .recreateCollection( getPersister().getRole() ); } }