/** * 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()); } }
/** * Initialize the delete all query. * This query is used to delete the collection of objects from the * database. */ protected void initializeDeleteAllQuery() { ((DeleteAllQuery)getDeleteAllQuery()).setReferenceClass(getReferenceClass()); if (!hasCustomDeleteAllQuery()) { // the selection criteria are re-used by the delete all query if (getSelectionCriteria() == null) { getDeleteAllQuery().setSelectionCriteria(buildDefaultSelectionCriteriaAndAddFieldsToQuery()); } else { getDeleteAllQuery().setSelectionCriteria(getSelectionCriteria()); } } }
/** * Delete all the reference objects with a single query. */ protected void deleteAll(DeleteObjectQuery query) throws DatabaseException { Object attribute = getAttributeAccessor().getAttributeValueFromObject(query.getObject()); if(usesIndirection()) { if(attribute == null || !getIndirectionPolicy().objectIsInstantiated(attribute)) { // An empty Vector indicates to DeleteAllQuery that no objects should be removed from cache ((DeleteAllQuery)getDeleteAllQuery()).executeDeleteAll(query.getSession().getSessionForClass(getReferenceClass()), query.getTranslationRow(), new Vector(0)); return; } } Object referenceObjects = this.getRealCollectionAttributeValueFromObject(query.getObject(), query.getSession()); ((DeleteAllQuery)getDeleteAllQuery()).executeDeleteAll(query.getSession().getSessionForClass(getReferenceClass()), query.getTranslationRow(), getContainerPolicy().vectorFor(referenceObjects, query.getSession())); }