private boolean isFoundInParent( String property, Object childEntity, EntityPersister persister, CollectionPersister collectionPersister, Object potentialParent) { final Object collection = persister.getPropertyValue( potentialParent, property ); return collection != null && Hibernate.isInitialized( collection ) && collectionPersister.getCollectionType().contains( collection, childEntity, session ); }
private Object getIndexInParent( String property, Object childEntity, EntityPersister persister, CollectionPersister collectionPersister, Object potentialParent){ final Object collection = persister.getPropertyValue( potentialParent, property ); if ( collection != null && Hibernate.isInitialized( collection ) ) { return collectionPersister.getCollectionType().indexOf( collection, childEntity ); } else { return null; } }
@Override public Object[] extractNaturalIdValues(Object entity, EntityPersister persister) { if ( entity == null ) { throw new AssertionFailure( "Entity from which to extract natural id value(s) cannot be null" ); } if ( persister == null ) { throw new AssertionFailure( "Persister to use in extracting natural id value(s) cannot be null" ); } final int[] naturalIdentifierProperties = persister.getNaturalIdentifierProperties(); final Object[] naturalIdValues = new Object[naturalIdentifierProperties.length]; for ( int i = 0; i < naturalIdentifierProperties.length; i++ ) { naturalIdValues[i] = persister.getPropertyValue( entity, naturalIdentifierProperties[i] ); } return naturalIdValues; }
/** * This version is slightly different for say * {@link org.hibernate.type.CollectionType#getKeyOfOwner} in that here we * need to assume that the owner is not yet associated with the session, * and thus we cannot rely on the owner's EntityEntry snapshot... * * @param role The persister for the collection role being processed. * * @return The value from the owner that identifies the grouping into the collection */ final Serializable extractCollectionKeyFromOwner(CollectionPersister role) { if ( role.getCollectionType().useLHSPrimaryKey() ) { return ownerIdentifier; } return (Serializable) role.getOwnerEntityPersister().getPropertyValue( owner, role.getCollectionType().getLHSPropertyName() ); } }
protected Serializable getCollectionKey( CollectionPersister persister, Object owner, EntityEntry ownerEntry, SharedSessionContractImplementor session) { final CollectionType collectionType = persister.getCollectionType(); if ( ownerEntry != null ) { // this call only works when the owner is associated with the Session, which is not always the case return collectionType.getKeyOfOwner( owner, session ); } if ( collectionType.getLHSPropertyName() == null ) { // collection key is defined by the owning entity identifier return persister.getOwnerEntityPersister().getIdentifier( owner, session ); } else { return (Serializable) persister.getOwnerEntityPersister().getPropertyValue( owner, collectionType.getLHSPropertyName() ); } }
Object ref = persister.getPropertyValue( entity, i ); Serializable id = getIdentifier( session, ref );
protected final Object getIdentifier(Object value, SharedSessionContractImplementor session) throws HibernateException { if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) { return ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session ); //tolerates nulls } else if ( value == null ) { return null; } else { EntityPersister entityPersister = getAssociatedEntityPersister( session.getFactory() ); Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName ); // We now have the value of the property-ref we reference. However, // we need to dig a little deeper, as that property might also be // an entity type, in which case we need to resolve its identitifier Type type = entityPersister.getPropertyType( uniqueKeyPropertyName ); if ( type.isEntityType() ) { propertyValue = ( (EntityType) type ).getIdentifier( propertyValue, session ); } return propertyValue; } }
@Override public void noCascade( EventSource session, Object parent, EntityPersister persister, Type propertyType, int propertyIndex) { if ( propertyType.isEntityType() ) { Object child = persister.getPropertyValue( parent, propertyIndex ); String childEntityName = ((EntityType) propertyType).getAssociatedEntityName( session.getFactory() ); if ( child != null && !isInManagedState( child, session ) && !(child instanceof HibernateProxy) //a proxy cannot be transient and it breaks ForeignKeys.isTransient && ForeignKeys.isTransient( childEntityName, child, null, session ) ) { String parentEntityName = persister.getEntityName(); String propertyName = persister.getPropertyNames()[propertyIndex]; throw new TransientPropertyValueException( "object references an unsaved transient instance - save the transient instance before flushing", childEntityName, parentEntityName, propertyName ); } } }
id = entityEntry.getPersister().getPropertyValue( owner, foreignKeyPropertyName );
Object associatedObject = persister.getPropertyValue( object, propertyName ); if ( associatedObject == null ) { throw new IdentifierGenerationException(
if ( association == null ) { association = sessionFactory.getMetamodel().entityPersister( entityName ).getPropertyValue( entity, virtualIdComponent.getPropertyNames()[i]
child = persister.getPropertyValue( parent, i ); componentPathStackDepth, parent, persister.getPropertyValue( parent, i ), types[ i ], style,
@Override public Object getPropertyValue(final Object object, final String propertyName) throws HibernateException { try { return persister.getPropertyValue(object, propertyName); } catch (final PersistenceException ex) { throw HibernateExceptionAdapter.adapt(ex); } }
@Override public Object getPropertyValue(final Object object, final int i) throws HibernateException { try { return persister.getPropertyValue(object, i); } catch (final PersistenceException ex) { throw HibernateExceptionAdapter.adapt(ex); } }
private static String getUid(EntityPersister persister, Object entity) { for (int i = 0; i < persister.getPropertyNames().length; i++) { if ("uid".equals(persister.getPropertyNames()[i])) return (String)persister.getPropertyValue(entity, i); } return null; }
private boolean isFoundInParent( String property, Object childEntity, EntityPersister persister, CollectionPersister collectionPersister, Object potentialParent) { Object collection = persister.getPropertyValue( potentialParent, property ); return collection != null && Hibernate.isInitialized( collection ) && collectionPersister.getCollectionType().contains( collection, childEntity, session ); }
private boolean isFoundInParent( String property, Object childEntity, EntityPersister persister, CollectionPersister collectionPersister, Object potentialParent) { Object collection = persister.getPropertyValue( potentialParent, property ); return collection != null && Hibernate.isInitialized( collection ) && collectionPersister.getCollectionType().contains( collection, childEntity, session ); }
private Object getIndexInParent( String property, Object childEntity, EntityPersister persister, CollectionPersister collectionPersister, Object potentialParent){ Object collection = persister.getPropertyValue( potentialParent, property ); if ( collection!=null && Hibernate.isInitialized(collection) ) { return collectionPersister.getCollectionType().indexOf(collection, childEntity); } else { return null; } }
private Object getIndexInParent( String property, Object childEntity, EntityPersister persister, CollectionPersister collectionPersister, Object potentialParent){ Object collection = persister.getPropertyValue( potentialParent, property ); if ( collection!=null && Hibernate.isInitialized(collection) ) { return collectionPersister.getCollectionType().indexOf(collection, childEntity); } else { return null; } }
protected final Object getIdentifier(Object value, SessionImplementor session) throws HibernateException { if ( isNotEmbedded(session) ) return value; if ( isReferenceToPrimaryKey() ) { return ForeignKeys.getEntityIdentifierIfNotUnsaved(associatedEntityName, value, session); //tolerates nulls } else if (value==null) { return null; } else { return session.getFactory() .getEntityPersister( getAssociatedEntityName() ) .getPropertyValue( value, uniqueKeyPropertyName, session.getEntityMode() ); } }