protected void addForeignKeyFieldToSourceTargetTable(OneToManyMapping mapping) { if (mapping.getDescriptor().hasTablePerClassPolicy()) { return; } addForeignMappingFkConstraint(mapping.getTargetForeignKeysToSourceKeys(), mapping.isCascadeOnDeleteSetOnDatabase()); if (mapping.getListOrderField() != null) { FieldDefinition fieldDef = getFieldDefFromDBField(mapping.getListOrderField()); TableDefinition table = getTableDefFromDBTable(mapping.getListOrderField().getTable()); if (!table.getFields().contains(fieldDef)) { table.addField(fieldDef); } } }
protected void addForeignKeyFieldToSourceTargetTable(OneToManyMapping mapping) { if (mapping.getDescriptor().hasTablePerClassPolicy()) { return; } addForeignMappingFkConstraint(mapping.getTargetForeignKeysToSourceKeys(), mapping.isCascadeOnDeleteSetOnDatabase()); if (mapping.getListOrderField() != null) { FieldDefinition fieldDef = getFieldDefFromDBField(mapping.getListOrderField()); TableDefinition table = getTableDefFromDBTable(mapping.getListOrderField().getTable()); if (!table.getFields().contains(fieldDef)) { table.addField(fieldDef); } } }
/** * Initialize the delete all query. * This query is used to delete the collection of objects from the * database. */ protected void initializeDeleteAllQuery(AbstractSession session) { ((DeleteAllQuery)getDeleteAllQuery()).setReferenceClass(getReferenceClass()); getDeleteAllQuery().setName(getAttributeName()); ((DeleteAllQuery)getDeleteAllQuery()).setIsInMemoryOnly(isCascadeOnDeleteSetOnDatabase()); if (!hasCustomDeleteAllQuery()) { // the selection criteria are re-used by the delete all query if (getSelectionCriteria() == null) { getDeleteAllQuery().setSelectionCriteria(buildDefaultSelectionCriteriaAndAddFieldsToQuery()); } else { getDeleteAllQuery().setSelectionCriteria(getSelectionCriteria()); } } if (!getDeleteAllQuery().hasSessionName()) { getDeleteAllQuery().setSessionName(session.getName()); } if (getDeleteAllQuery().getPartitioningPolicy() == null) { getDeleteAllQuery().setPartitioningPolicy(getPartitioningPolicy()); } }
/** * Initialize the delete all query. * This query is used to delete the collection of objects from the * database. */ protected void initializeDeleteAllQuery(AbstractSession session) { ((DeleteAllQuery)getDeleteAllQuery()).setReferenceClass(getReferenceClass()); getDeleteAllQuery().setName(getAttributeName()); ((DeleteAllQuery)getDeleteAllQuery()).setIsInMemoryOnly(isCascadeOnDeleteSetOnDatabase()); if (!hasCustomDeleteAllQuery()) { // the selection criteria are re-used by the delete all query if (getSelectionCriteria() == null) { getDeleteAllQuery().setSelectionCriteria(buildDefaultSelectionCriteriaAndAddFieldsToQuery()); } else { getDeleteAllQuery().setSelectionCriteria(getSelectionCriteria()); } } if (!getDeleteAllQuery().hasSessionName()) { getDeleteAllQuery().setSessionName(session.getName()); } if (getDeleteAllQuery().getPartitioningPolicy() == null) { getDeleteAllQuery().setPartitioningPolicy(getPartitioningPolicy()); } }