/** * INTERNAL: * Checks if object is deleted from the database or not. */ public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); Object value = session.executeQuery(getSelectionQuery(), row); return getContainerPolicy().isEmpty(value); }
/** * INTERNAL: * Checks if object is deleted from the database or not. */ public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); Object value = session.executeQuery(getSelectionQuery(), row); return getContainerPolicy().isEmpty(value); }
/** * INTERNAL: * Checks if object is deleted from the database or not. */ @Override public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); Object value = session.executeQuery(getSelectionQuery(), row); return getContainerPolicy().isEmpty(value); }
/** * INTERNAL: * Checks if object is deleted from the database or not. */ @Override public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); Object value = session.executeQuery(getSelectionQuery(), row); return getContainerPolicy().isEmpty(value); }
/** * INTERNAL: * Checks if object is deleted from the database or not. */ @Override public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); Object value = session.executeQuery(getSelectionQuery(), row); return getContainerPolicy().isEmpty(value); }
/** * INTERNAL: * Checks if object is deleted from the database or not. */ @Override public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); Object value = session.executeQuery(getSelectionQuery(), row); return getContainerPolicy().isEmpty(value); }
/** * INTERNAL: * Prepare the receiver for execution in a session. In particular, * verify that the object is not null and contains a valid primary key. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // Set the translation row if ((this.translationRow == null) || this.translationRow.isEmpty()) { if (this.isFullRowRequired) { this.translationRow = this.descriptor.getObjectBuilder().buildRow(this.object, this.session, WriteType.UNDEFINED); } else { this.translationRow = this.descriptor.getObjectBuilder().buildRowForTranslation(this.object, this.session); } } // Add the write lock field if required if (this.usesOptimisticLocking) { this.descriptor.getOptimisticLockingPolicy().addLockValuesToTranslationRow(this); } } }
/** * INTERNAL: * Prepare the receiver for execution in a session. In particular, * verify that the object is not null and contains a valid primary key. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // Set the translation row if ((this.translationRow == null) || this.translationRow.isEmpty()) { if (this.isFullRowRequired) { this.translationRow = this.descriptor.getObjectBuilder().buildRow(this.object, this.session, WriteType.UNDEFINED); } else { this.translationRow = this.descriptor.getObjectBuilder().buildRowForTranslation(this.object, this.session); } } // Add the write lock field if required if (this.usesOptimisticLocking) { this.descriptor.getOptimisticLockingPolicy().addLockValuesToTranslationRow(this); } } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // Set the tranlation row, it may already be set in the custom query situation. // PERF: Only build the translation row for updates, as inserts do not have a where clause. if ((!isInsertObjectQuery()) && ((getTranslationRow() == null) || (getTranslationRow().isEmpty()))) { setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getObject(), getSession())); } } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // Set the tranlation row, it may already be set in the custom query situation. // PERF: Only build the translation row for updates, as inserts do not have a where clause. if ((!isInsertObjectQuery()) && ((getTranslationRow() == null) || (getTranslationRow().isEmpty()))) { setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getObject(), getSession())); } } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // Set the tranlation row, it may already be set in the custom query situation. // PERF: Only build the translation row for updates, as inserts do not have a where clause. if ((!isInsertObjectQuery()) && ((getTranslationRow() == null) || (getTranslationRow().isEmpty()))) { setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getObject(), getSession())); } } }
/** * INTERNAL: * Prepare the receiver for execution in a session. In particular, * verify that the object is not null and contains a valid primary key. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // Set the translation row if ((this.translationRow == null) || this.translationRow.isEmpty()) { if (this.isFullRowRequired) { this.translationRow = this.descriptor.getObjectBuilder().buildRow(this.object, this.session); } else { this.translationRow = this.descriptor.getObjectBuilder().buildRowForTranslation(this.object, this.session); } } // Add the write lock field if required if (this.descriptor.usesOptimisticLocking()) { this.descriptor.getOptimisticLockingPolicy().addLockValuesToTranslationRow(this); } } }
/** * Update the foreign key fields when resolving a bi-directonal reference in a UOW. * This must always be dynamic as it is called within an insert query and is really part of the insert * and does not fire update events or worry about locking. */ protected void updateForeignKeyFieldAfterInsert() { WriteObjectQuery writeQuery = getWriteObjectQuery(); Object object = writeQuery.getObject(); writeQuery.setPrimaryKey(getDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(object, getSession())); // reset the translation row because the insert has occurred and the id has // been assigned to the object, but not the row writeQuery.setTranslationRow(getDescriptor().getObjectBuilder().buildRowForTranslation(object, getSession())); updateForeignKeyFieldAfterInsert(writeQuery); }
/** * Update the foreign key fields when resolving a bi-directonal reference in a UOW. * This must always be dynamic as it is called within an insert query and is really part of the insert * and does not fire update events or worry about locking. */ protected void updateForeignKeyFieldAfterInsert() { WriteObjectQuery writeQuery = getWriteObjectQuery(); Object object = writeQuery.getObject(); writeQuery.setPrimaryKey(getDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(object, getSession())); // reset the translation row because the insert has occurred and the id has // been assigned to the object, but not the row writeQuery.setTranslationRow(getDescriptor().getObjectBuilder().buildRowForTranslation(object, getSession())); updateForeignKeyFieldAfterInsert(writeQuery); }
/** * Update the foreign key fields when resolving a bi-directonal reference in a UOW. * This must always be dynamic as it is called within an insert query and is really part of the insert * and does not fire update events or worry about locking. */ protected void updateForeignKeyFieldAfterInsert() { WriteObjectQuery writeQuery = getWriteObjectQuery(); Object object = writeQuery.getObject(); writeQuery.setPrimaryKey(getDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(object, getSession())); // reset the translation row because the insert has occurred and the id has // been assigned to the object, but not the row writeQuery.setTranslationRow(getDescriptor().getObjectBuilder().buildRowForTranslation(object, getSession())); updateForeignKeyFieldAfterInsert(writeQuery); }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // For bug 2989998 the translation row now sometimes set earlier in prepare. if (shouldPrepare()) { if (getSelectionKey() != null) { // Row must come from the key. setTranslationRow(this.descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(getSelectionKey(), getSession())); } else if (getSelectionObject() != null) { // The expression is set in the prepare as params. setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getSelectionObject(), getSession())); } } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); if (getObject() == null) { throw QueryException.objectToModifyNotSpecified(this); } setObject(this.descriptor.getObjectBuilder().unwrapObject(getObject(), getSession())); if (this.descriptor == null) { setDescriptor(getSession().getDescriptor(getObject().getClass())); } if (getPrimaryKey() == null) { setPrimaryKey(this.descriptor.getObjectBuilder().extractPrimaryKeyFromObject(getObject(), getSession())); } if ((getTranslationRow() == null) || (getTranslationRow().isEmpty())) { setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getObject(), getSession())); } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); if (getObject() == null) { throw QueryException.objectToModifyNotSpecified(this); } setObject(this.descriptor.getObjectBuilder().unwrapObject(getObject(), getSession())); if (this.descriptor == null) { setDescriptor(getSession().getDescriptor(getObject().getClass())); } if (getPrimaryKey() == null) { setPrimaryKey(this.descriptor.getObjectBuilder().extractPrimaryKeyFromObject(getObject(), getSession())); } if ((getTranslationRow() == null) || (getTranslationRow().isEmpty())) { setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getObject(), getSession())); } }
/** * INTERNAL: * Checks if object is deleted from the database or not. */ @Override public boolean verifyDelete(Object object, AbstractSession session) throws DatabaseException { // Row is built for translation if (isReadOnly()) { return true; } if (isPrivateOwned() || isCascadeRemove()) { Object objects = getRealCollectionAttributeValueFromObject(object, session); ContainerPolicy containerPolicy = this.containerPolicy; for (Object iter = containerPolicy.iteratorFor(objects); containerPolicy.hasNext(iter);) { if (!session.verifyDelete(containerPolicy.next(iter, session))) { return false; } } } AbstractRecord row = getDescriptor().getObjectBuilder().buildRowForTranslation(object, session); //cr 3819 added the line below to fix the translationtable to ensure that it // contains the required values prepareTranslationRow(row, object, getDescriptor(), session); Object value = session.executeQuery(getSelectionQuery(), row); return this.containerPolicy.isEmpty(value); }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); if (getObject() == null) { throw QueryException.objectToModifyNotSpecified(this); } setObject(this.descriptor.getObjectBuilder().unwrapObject(getObject(), getSession())); if (this.descriptor == null) { setDescriptor(getSession().getDescriptor(getObject().getClass())); } if (getPrimaryKey() == null) { setPrimaryKey(this.descriptor.getObjectBuilder().extractPrimaryKeyFromObject(getObject(), getSession())); } if ((getTranslationRow() == null) || (getTranslationRow().isEmpty())) { setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getObject(), getSession())); } }