/** * PUBLIC: * Checks if the database row is empty (ie. there are no field-value pairs.) * @return boolean - true if the database row is empty */ public boolean isEmpty() { return super.isEmpty(); }
/** * Perform a cache lookup for the query. * If the translation row contains all the primary key fields, * then a cache check will be performed. * If the object is found in the cache, return it; * otherwise return null. */ public Object checkCacheForObject(AbstractRecord translationRow, AbstractSession session) { // Null check added for CR#4295 - TW if ((translationRow == null) || (translationRow.isEmpty())) { return null; } List keyFields = getDescriptor().getPrimaryKeyFields(); Vector primaryKey = new Vector(keyFields.size()); for (int index = 0; index < keyFields.size(); index++) { Object value = translationRow.get((DatabaseField)keyFields.get(index)); if (value == null) { return null; } else { primaryKey.add(value); } } return session.getIdentityMapAccessorInstance().getFromIdentityMapWithDeferredLock(primaryKey, getReadObjectQuery().getReferenceClass(), false, getDescriptor()); }
/** * 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. if ((getTranslationRow() == null) || (getTranslationRow().isEmpty())) { setTranslationRow(getDescriptor().getObjectBuilder().buildRowForTranslation(getObject(), getSession())); } }
protected void updateObjectAndRowWithReturnRow(Collection returnFields, boolean isFirstCallForInsert) { WriteObjectQuery writeQuery = getWriteObjectQuery(); AbstractRecord outputRow = (AbstractRecord)writeQuery.getProperties().get("output"); if ((outputRow == null) || outputRow.isEmpty()) { return; if (row.isEmpty()) { return; if (!pkToModify.isEmpty()) { primaryKeys = getDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(object, getSession()); writeQuery.setPrimaryKey(primaryKeys);
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); if (getObject() == null) { throw QueryException.objectToModifyNotSpecified(this); } setObject(getDescriptor().getObjectBuilder().unwrapObject(getObject(), getSession())); if (getDescriptor() == null) { setDescriptor(getSession().getDescriptor(getObject().getClass())); } if (getPrimaryKey() == null) { setPrimaryKey(getDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(getObject(), getSession())); } if ((getTranslationRow() == null) || (getTranslationRow().isEmpty())) { setTranslationRow(getDescriptor().getObjectBuilder().buildRowForTranslation(getObject(), getSession())); } }
/** * INTERNAL: * Check to see if this query needs to be prepare and prepare it. * The prepare is done on the original query to ensure that the work is not repeated. */ public void checkPrepare(AbstractSession session, AbstractRecord translationRow) { // This query is first prepared for global common state, this must be synced. if (!isPrepared()) {// Avoid the monitor is already prepare, must check again for concurrency. // Prepared queries cannot be custom as then they would never have been prepared. synchronized (this) { if (!isPrepared()) { // When custom SQL is used there is a possibility that the SQL contains the # token. // Avoid this by telling the call if this is custom SQL with parameters. // This must not be called for SDK calls. if ((isReadQuery() || isDataModifyQuery()) && isCallQuery() && (getQueryMechanism() instanceof CallQueryMechanism) && ((translationRow == null) || translationRow.isEmpty())) { // Must check for read object queries as the row will be empty until the prepare. if (isReadObjectQuery() || isUserDefined()) { ((CallQueryMechanism)getQueryMechanism()).setCallHasCustomSQLArguments(); } } else if (isCallQuery() && (getQueryMechanism() instanceof CallQueryMechanism)) { ((CallQueryMechanism)getQueryMechanism()).setCallHasCustomSQLArguments(); } setSession(session);// Session is required for some init stuff. prepare(); setSession(null); setIsPrepared(true);// MUST not set prepare until done as other thread may hit before finihsing the prepare. } } } }
if (!getModifyRow().isEmpty() || (shouldModifyVersionField != null) || writeQuery.getObjectChangeSet().hasCmpPolicyForcedUpdate()) { policy.addLockValuesToTranslationRow(writeQuery); if (!getModifyRow().isEmpty() || (shouldModifyVersionField.booleanValue() && policy instanceof VersionLockingPolicy)) {
if (!getModifyRow().isEmpty()) {