/** * 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())); }
/** * 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, AbstractSession session) throws DatabaseException { Object attribute = getAttributeValueFromObject(query.getObject()); if (usesIndirection()) { if (!this.indirectionPolicy.objectIsInstantiated(attribute)) { // An empty Vector indicates to DeleteAllQuery that no objects should be removed from cache ((DeleteAllQuery)this.deleteAllQuery).executeDeleteAll(session.getSessionForClass(this.referenceClass), query.getTranslationRow(), new Vector(0)); return; } } Object referenceObjects = getRealCollectionAttributeValueFromObject(query.getObject(), session); // PERF: Avoid delete if empty. if (session.isUnitOfWork() && this.containerPolicy.isEmpty(referenceObjects)) { return; } ((DeleteAllQuery)this.deleteAllQuery).executeDeleteAll(session.getSessionForClass(getReferenceClass()), query.getTranslationRow(), this.containerPolicy.vectorFor(referenceObjects, session)); }
/** * Delete all the reference objects with a single query. */ protected void deleteAll(DeleteObjectQuery query, AbstractSession session) throws DatabaseException { Object attribute = getAttributeValueFromObject(query.getObject()); if (usesIndirection()) { if (!this.indirectionPolicy.objectIsInstantiated(attribute)) { // An empty Vector indicates to DeleteAllQuery that no objects should be removed from cache ((DeleteAllQuery)this.deleteAllQuery).executeDeleteAll(session.getSessionForClass(this.referenceClass), query.getTranslationRow(), new Vector(0)); return; } } Object referenceObjects = getRealCollectionAttributeValueFromObject(query.getObject(), session); // PERF: Avoid delete if empty. if (session.isUnitOfWork() && this.containerPolicy.isEmpty(referenceObjects)) { return; } ((DeleteAllQuery)this.deleteAllQuery).executeDeleteAll(session.getSessionForClass(getReferenceClass()), query.getTranslationRow(), this.containerPolicy.vectorFor(referenceObjects, session)); }
OneToManyMapping mapping = (OneToManyMapping)databaseMapping; if (mapping.getMappedBy() != null) { Class<?> referenceClass = mapping.getReferenceClass(); ClassDescriptor referenceClassDescriptor = getClassDescriptor(referenceClass); return referenceClassDescriptor.getMappingForAttributeName(mapping.getMappedBy());
public void initialize(AbstractSession session) throws DescriptorException { if (session.hasBroker()) { if (getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); session = session.getBroker().getSessionForClass(getReferenceClass());
public void initialize(AbstractSession session) throws DescriptorException { if (session.hasBroker()) { if (getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); session = session.getBroker().getSessionForClass(getReferenceClass());
if (SoftDelete.class.isAssignableFrom(oneToManyMapping.getReferenceClass())) { oneToManyMapping.setAdditionalJoinCriteria(new ExpressionBuilder().get("deleteTs").isNull());
/** * 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()); } }