private int calculateForeignKeyColumnCount(PersistentEntity refDomainClass, String[] propertyNames) { int expectedForeignKeyColumnLength = 0; for (String propertyName : propertyNames) { PersistentProperty referencedProperty = refDomainClass.getPropertyByName(propertyName); if(referencedProperty instanceof ToOne) { ToOne toOne = (ToOne) referencedProperty; PersistentProperty[] compositeIdentity = toOne.getAssociatedEntity().getCompositeIdentity(); if(compositeIdentity != null) { expectedForeignKeyColumnLength += compositeIdentity.length; } else { expectedForeignKeyColumnLength++; } } else { expectedForeignKeyColumnLength++; } } return expectedForeignKeyColumnLength; }
PersistentProperty[] compositeIdentity = toOne.getAssociatedEntity().getCompositeIdentity(); if(compositeIdentity != null) { for (PersistentProperty cip : compositeIdentity) {
if (association.isBidirectional() && association.getAssociatedEntity() != null) { Query query = session.createQuery(association.getAssociatedEntity().getJavaClass()); query.eq(association.getInverseSide().getName(), obj) .projections().id(); PersistentEntity associatedEntity = ((ToOne) prop).getAssociatedEntity(); associatedEntity = discriminatePersistentEntity(associatedEntity, (T) tmp); Object instance = newEntityInstance(associatedEntity); PersistentEntity associatedEntity = association.getAssociatedEntity(); if(associatedEntity != null) { final Serializable associationKey = convertIdIfNecessary(associatedEntity, tmp);
else if (association.getAssociatedEntity() != null) { final Object associatedObject = entityAccess.getProperty(prop.getName()); if (associatedObject != null) { T cachedAssociationEntry = (T) si.getCachedEntry(association.getAssociatedEntity(), associationId); if (cachedAssociationEntry != null) { if (association.isBidirectional()) { Association inverseSide = association.getInverseSide(); if (inverseSide != null) { setEntryValue(cachedAssociationEntry, inverseSide.getName(), formulateDatabaseReference(association.getAssociatedEntity(), inverseSide, (Serializable) k)); } else { setEntryValue(cachedAssociationEntry, key, formulateDatabaseReference(association.getAssociatedEntity(), inverseSide, (Serializable) k)); EntityAccess inverseAccess = createEntityAccess(association.getAssociatedEntity(), inverseEntity); Object entity = entityAccess.getEntity(); if (inverse instanceof OneToMany) {