@Override public EntityKey generateEntityKey(Serializable id, EntityPersister persister) { return new EntityKey( id, persister ); }
/** * Custom deserialization routine used during deserialization of a * Session/PersistenceContext for increased performance. * * @param ois The stream from which to read the entry. * @param sessionFactory The SessionFactory owning the Session being deserialized. * * @return The deserialized EntityEntry * * @throws IOException Thrown by Java I/O * @throws ClassNotFoundException Thrown by Java I/O */ public static EntityKey deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) throws IOException, ClassNotFoundException { final Serializable id = (Serializable) ois.readObject(); final String entityName = (String) ois.readObject(); final EntityPersister entityPersister = sessionFactory.getEntityPersister( entityName ); return new EntityKey(id, entityPersister); } }
@Override public EntityKey getEntityKey() { if ( cachedEntityKey == null ) { if ( getId() == null ) { throw new IllegalStateException( "cannot generate an EntityKey when id is null."); } cachedEntityKey = new EntityKey( getId(), getPersister() ); } return cachedEntityKey; }
final List<Serializable> nonManagedIds = new ArrayList<Serializable>(); for ( Serializable id : ids ) { final EntityKey entityKey = new EntityKey( id, persister );
final EntityKey entityKey = new EntityKey( id, persister );
private static void checkInBatchFetchQueue(long id, Session session, boolean expected) { final SessionImplementor sessionImplementor = (SessionImplementor) session; final EntityPersister persister = sessionImplementor.getFactory().getMetamodel().entityPersister( Task.class ); final BatchFetchQueue batchFetchQueue = sessionImplementor.getPersistenceContext().getBatchFetchQueue(); assertEquals( expected, batchFetchQueue.containsEntityKey( new EntityKey( id, persister ) ) ); }
new EntityKey( ( (SessionImplementor) session ).getContextEntityIdentifier( a2.getB() ), ( (SessionImplementor) session ).getFactory().getEntityPersister( B.class.getName() )
@Override public EntityKey generateEntityKey(Object id, EntityTypeDescriptor descriptor) { return new EntityKey( id, descriptor ); }
@Override public EntityKey generateEntityKey(Serializable id, EntityPersister persister) { return new EntityKey( id, persister, getTenantIdentifier() ); }
@Override public EntityKey generateEntityKey(Serializable id, EntityPersister persister) { return new EntityKey( id, persister, getTenantIdentifier() ); }
/** * Custom deserialization routine used during deserialization of a * Session/PersistenceContext for increased performance. * * @param ois The stream from which to read the entry. * @param sessionFactory The SessionFactory owning the Session being deserialized. * * @return The deserialized EntityEntry * * @throws IOException Thrown by Java I/O * @throws ClassNotFoundException Thrown by Java I/O */ public static EntityKey deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) throws IOException, ClassNotFoundException { final Serializable id = (Serializable) ois.readObject(); final String entityName = (String) ois.readObject(); final EntityTypeDescriptor entityDescriptor = sessionFactory.getEntityPersister( entityName ); return new EntityKey( id, entityDescriptor ); } }
/** * Custom deserialization routine used during deserialization of a * Session/PersistenceContext for increased performance. * * @param ois The stream from which to read the entry. * @param session The session being deserialized. * * @return The deserialized EntityEntry * * @throws IOException Thrown by Java I/O * @throws ClassNotFoundException Thrown by Java I/O */ public static EntityKey deserialize( ObjectInputStream ois, SessionImplementor session) throws IOException, ClassNotFoundException { return new EntityKey( ( Serializable ) ois.readObject(), (String) ois.readObject(), (String) ois.readObject(), ( Type ) ois.readObject(), ois.readBoolean(), ( session == null ? null : session.getFactory() ), (String) ois.readObject() ); } }
/** * Custom deserialization routine used during deserialization of a * Session/PersistenceContext for increased performance. * * @param ois The stream from which to read the entry. * @param session The session being deserialized. * * @return The deserialized EntityEntry * * @throws IOException Thrown by Java I/O * @throws ClassNotFoundException Thrown by Java I/O */ public static EntityKey deserialize( ObjectInputStream ois, SessionImplementor session) throws IOException, ClassNotFoundException { return new EntityKey( ( Serializable ) ois.readObject(), (String) ois.readObject(), (String) ois.readObject(), ( Type ) ois.readObject(), ois.readBoolean(), ( session == null ? null : session.getFactory() ), (String) ois.readObject() ); } }
@Override public EntityKey getEntityKey() { if ( cachedEntityKey == null ) { if ( getId() == null ) { throw new IllegalStateException( "cannot generate an EntityKey when id is null."); } cachedEntityKey = new EntityKey( getId(), getDescriptor() ); } return cachedEntityKey; }
/** * Get the EntityKey based on this EntityEntry. * @return the EntityKey * @throws IllegalStateException if getId() is null */ public EntityKey getEntityKey() { if ( cachedEntityKey == null ) { if ( getId() == null ) { throw new IllegalStateException( "cannot generate an EntityKey when id is null."); } cachedEntityKey = new EntityKey( getId(), getPersister(), tenantId ); } return cachedEntityKey; }
/** * Get the EntityKey based on this EntityEntry. * @return the EntityKey * @throws IllegalStateException if getId() is null */ public EntityKey getEntityKey() { if ( cachedEntityKey == null ) { if ( getId() == null ) { throw new IllegalStateException( "cannot generate an EntityKey when id is null."); } cachedEntityKey = new EntityKey( getId(), getPersister(), tenantId ); } return cachedEntityKey; }
@Override public int getSize(Serializable key, SharedSessionContractImplementor session) { AssociationPersister associationPersister = getAssociationPersister( session.getPersistenceContext().getEntity( new org.hibernate.engine.spi.EntityKey( key, getOwnerEntityPersister() ) ), key, session ); final Association collectionMetadata = associationPersister.getAssociationOrNull(); return collectionMetadata == null ? 0 : collectionMetadata.size(); }
@SuppressWarnings("WeakerAccess") protected void resolveEntityKey(RowProcessingState rowProcessingState) { if ( entityKey != null ) { // its already been resolved return; } final SharedSessionContractImplementor session = rowProcessingState.getJdbcValuesSourceProcessingState().getSession(); // 1) resolve the hydrated identifier value(s) into its identifier representation final Object id = identifierAssembler.assemble( rowProcessingState, rowProcessingState.getJdbcValuesSourceProcessingState().getProcessingOptions() ); if ( id == null ) { missing = true; // EARLY EXIT!!! return; } // 2) build the EntityKey this.entityKey = new EntityKey( id, concreteDescriptor.getEntityDescriptor() ); // 3) schedule the EntityKey for batch loading, if possible if ( concreteDescriptor.getEntityDescriptor().isBatchLoadable() ) { if ( !session.getPersistenceContext().containsEntity( entityKey ) ) { session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey ); } } // todo (6.0) : subselect fetches similar to batch fetch handling above }
entityKey = new EntityKey( keyValue, getEntityDescriptor() );
.session( session ) .associationTypeContext( associationTypeContext ) .hostingEntity( session.getPersistenceContext().getEntity( new org.hibernate.engine.spi.EntityKey( (Serializable) uniqueKey, inversePersister ) ) ) .build();