protected boolean isConstrainableProperty(PersistentProperty persistentProperty, String propertyName) { if(persistentProperty == null) { return NameUtils.isNotConfigurational(propertyName); } else { return !propertyName.equals(GormProperties.VERSION) && !propertyName.equals(GormProperties.DATE_CREATED) && !propertyName.equals(GormProperties.LAST_UPDATED) && !(persistentProperty instanceof Identity) && !(persistentProperty.getMapping().getMappedForm().isDerived()) && !( (persistentProperty instanceof ToOne) && ((ToOne)persistentProperty).isBidirectional() && ((ToOne) persistentProperty).isCircular()); } }
protected boolean isForeignKeyInChild(Association association) { return association instanceof ToOne && ((ToOne) association).isForeignKeyInChild() || association instanceof ToMany; }
else if (association.getAssociatedEntity() != null) { final Object associatedObject = entityAccess.getProperty(prop.getName()); if (associatedObject != null) { Serializable tempId = associationPersister.getObjectIdentifier(associatedObject); if (tempId == null) { if (association.doesCascade(CascadeType.PERSIST)) { tempId = session.persist(associatedObject); if (association.isForeignKeyInChild()) { 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)); if (association.isBidirectional()) { Association inverseSide = association.getInverseSide(); if (inverseSide != null) { EntityAccess inverseAccess = createEntityAccess(inverseSide.getOwner(), associatedObject); if( association.doesCascade(CascadeType.PERSIST) ) { associationPersister.persist(associatedObject); if (association.isBidirectional()) { Association inverse = association.getInverseSide();
if (!association.isForeignKeyInChild()) { tmp = (Serializable) getEntryValue(nativeEntry, propKey); 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);
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; }
association.setAssociatedEntity(associatedEntity); return association; association.setForeignKeyInChild(true); if (descriptors.size() > 0) { for (PropertyDescriptor descriptor : descriptors) { association.setForeignKeyInChild(false); entity.addOwner(propType); relatedClassPropertyName = descriptor.getName(); association.setForeignKeyInChild(true); List<PropertyDescriptor> descriptors = relatedCpf.getPropertiesOfType(entity.getJavaClass()); if (descriptors.size() > 0) { OneToOne relatedOneToOne = getAnnotation(relatedCpf, descriptor, OneToOne.class); if (relatedOneToOne != null && relatedOneToOne.mappedBy().equals(property.getName())) { association.setForeignKeyInChild(false); entity.addOwner(propType); relatedClassPropertyName = descriptor.getName(); association.setAssociatedEntity(associatedEntity); if (relatedClassPropertyName != null ) { association.setReferencedPropertyName(relatedClassPropertyName);
ToOne association = (ToOne) prop; if (!(prop instanceof Embedded) && !(prop instanceof EmbeddedCollection) && association.doesCascade(CascadeType.REMOVE)) { if (association.isOwningSide()) { Object value = entityAccess.getProperty(association.getName()); if (value != null) { Persister persister = session.getPersister(value);
PersistentProperty[] compositeIdentity = toOne.getAssociatedEntity().getCompositeIdentity(); if(compositeIdentity != null) { for (PersistentProperty cip : compositeIdentity) {
association.setAssociatedEntity(associatedEntity); return association; association.setForeignKeyInChild(true); association.setAssociatedEntity(associatedEntity); if (relatedClassPropertyName != null && relatedClassPropertyType != null) { association.setReferencedPropertyName(relatedClassPropertyName);
@Override public boolean isOwningSide() { return super.isOwningSide() || isForeignKeyInChild(); } }