/** * INTERNAL: * It is responsible for initializing the policy; */ public void initialize(AbstractSession session) { // If the version field is not in the primary table, then they cannot be batched together. if (this.descriptor.getTables().size() > 0) { this.descriptor.setHasMultipleTableConstraintDependecy(true); } }
/** * INTERNAL: * It is responsible for initializing the policy; */ public void initialize(AbstractSession session) { // If the version field is not in the primary table, then they cannot be batched together. if (this.descriptor.getTables().size() > 0) { this.descriptor.setHasMultipleTableConstraintDependecy(true); } }
private void setMultipleTableConstraintDependency(MetaClass metaClass, ClassDescriptor desc) { InheritancePolicy policy = desc.getInheritancePolicyOrNull(); if (policy != null && policy.isJoinedStrategy() && policy.getParentClass() != null) { boolean hasOneToMany = metaClass.getOwnProperties().stream().anyMatch(metaProperty -> metadata.getTools().isPersistent(metaProperty) && metaProperty.getRange().isClass() && metaProperty.getRange().getCardinality() == Range.Cardinality.ONE_TO_MANY); if (hasOneToMany) { desc.setHasMultipleTableConstraintDependecy(true); } } }
for (DatabaseField field : getSourceToTargetKeyFields().values()) { if (!field.getTable().equals(firstTable)) { getReferenceDescriptor().setHasMultipleTableConstraintDependecy(true); for (DatabaseField field : getSourceToTargetKeyFields().keySet()) { if (!field.getTable().equals(firstTable)) { getDescriptor().setHasMultipleTableConstraintDependecy(true);
for (DatabaseField field : getSourceToTargetKeyFields().values()) { if (!field.getTable().equals(firstTable)) { getReferenceDescriptor().setHasMultipleTableConstraintDependecy(true); for (DatabaseField field : getSourceToTargetKeyFields().keySet()) { if (!field.getTable().equals(firstTable)) { getDescriptor().setHasMultipleTableConstraintDependecy(true);
/** * INTERNAL: * Initialized the inheritance properties that cannot be initialized * until after the mappings have been. */ public void postInitialize(AbstractSession session) { if (isChildDescriptor()) { ClassDescriptor parent = getParentDescriptor(); if (getDescriptor().shouldAcquireCascadedLocks()){ parent.setShouldAcquireCascadedLocks(true); } if (getDescriptor().hasRelationships()){ parent.setHasRelationships(true); } while (parent != null) { if (parent.hasMultipleTableConstraintDependecy()) { getDescriptor().setHasMultipleTableConstraintDependecy(true); break; } parent = parent.getInheritancePolicy().getParentDescriptor(); } } }
/** * INTERNAL: * Initialized the inheritance properties that cannot be initialized * until after the mappings have been. */ public void postInitialize(AbstractSession session) { if (isChildDescriptor()) { ClassDescriptor parent = getParentDescriptor(); if (getDescriptor().shouldAcquireCascadedLocks()){ parent.setShouldAcquireCascadedLocks(true); } if (getDescriptor().hasRelationships()){ parent.setHasRelationships(true); } while (parent != null) { if (parent.hasMultipleTableConstraintDependecy()) { getDescriptor().setHasMultipleTableConstraintDependecy(true); break; } parent = parent.getInheritancePolicy().getParentDescriptor(); } } }
/** * INTERNAL: * It is responsible for initializing the policy; */ public void initialize(AbstractSession session) { DatabaseMapping mapping = this.descriptor.getObjectBuilder().getMappingForField(getWriteLockField()); if (mapping == null) { if (isStoredInObject()) { if (this.descriptor.getObjectBuilder().getReadOnlyMappingsForField(getWriteLockField()) != null) { mapping = this.descriptor.getObjectBuilder().getReadOnlyMappingsForField(getWriteLockField()).get(0); session.getIntegrityChecker().handleError(DescriptorException.mappingCanNotBeReadOnly(mapping)); } else { session.getIntegrityChecker().handleError(OptimisticLockException.mustHaveMappingWhenStoredInObject(this.descriptor.getJavaClass())); } } else { return; } } if (isStoredInCache()) { session.getIntegrityChecker().handleError(DescriptorException.mustBeReadOnlyMappingWhenStoredInCache(mapping)); } // PERF: Cache the mapping if direct. if (mapping.isDirectToFieldMapping() && (this.descriptor.getObjectBuilder().getReadOnlyMappingsForField(getWriteLockField()) == null)) { this.lockMapping = (AbstractDirectMapping)mapping; } // If the version field is not in the primary table, then they cannot be batched together. if ((this.descriptor.getTables().size() > 0) && !getWriteLockField().getTable().equals(this.descriptor.getTables().get(0))) { this.descriptor.setHasMultipleTableConstraintDependecy(true); } }
/** * INTERNAL: * It is responsible for initializing the policy; */ public void initialize(AbstractSession session) { DatabaseMapping mapping = this.descriptor.getObjectBuilder().getMappingForField(getWriteLockField()); if (mapping == null) { if (isStoredInObject()) { if (this.descriptor.getObjectBuilder().getReadOnlyMappingsForField(getWriteLockField()) != null) { mapping = this.descriptor.getObjectBuilder().getReadOnlyMappingsForField(getWriteLockField()).get(0); session.getIntegrityChecker().handleError(DescriptorException.mappingCanNotBeReadOnly(mapping)); } else { session.getIntegrityChecker().handleError(OptimisticLockException.mustHaveMappingWhenStoredInObject(this.descriptor.getJavaClass())); } } else { return; } } if (isStoredInCache()) { session.getIntegrityChecker().handleError(DescriptorException.mustBeReadOnlyMappingWhenStoredInCache(mapping)); } // PERF: Cache the mapping if direct. if (mapping.isDirectToFieldMapping() && (this.descriptor.getObjectBuilder().getReadOnlyMappingsForField(getWriteLockField()) == null)) { this.lockMapping = (AbstractDirectMapping)mapping; } // If the version field is not in the primary table, then they cannot be batched together. if ((this.descriptor.getTables().size() > 0) && !getWriteLockField().getTable().equals(this.descriptor.getTables().get(0))) { this.descriptor.setHasMultipleTableConstraintDependecy(true); } }
for (DatabaseField field : getSourceKeyFields()) { if (!field.getTable().equals(firstTable)) { getDescriptor().setHasMultipleTableConstraintDependecy(true);
for (DatabaseField field : getSourceKeyFields()) { if (!field.getTable().equals(firstTable)) { getDescriptor().setHasMultipleTableConstraintDependecy(true);
for (DatabaseField field : getSourceKeyFields()) { if (!field.getTable().equals(firstTable)) { getDescriptor().setHasMultipleTableConstraintDependecy(true);
for (DatabaseField field : getSourceKeyFields()) { if (!field.getTable().equals(firstTable)) { getDescriptor().setHasMultipleTableConstraintDependecy(true);