/** * ADVANCED: * Return the receiver's does-exist call. * This allows the user to override the does-exist operation. */ public Call getDoesExistCall() { if (getDoesExistQuery() == null) { return null; } return getDoesExistQuery().getDatasourceCall(); }
/** * ADVANCED: * Return the receiver's does exist SQL string. * This allows the user to override the SQL generated by TopLink, with there own SQL or procedure call. * The arguments are translated from the fields of the source row, through replacing the field names marked by '#' * with the values for those fields. * This must return null if the object does not exist, otherwise return a database row. * <p> * Example, "select EMPLOYEE_ID from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID". */ public String getDoesExistSQLString() { if (getDoesExistQuery() == null) { return null; } return getDoesExistQuery().getSQLString(); }
/** * PUBLIC: * Assume that if the objects primary key does not include null then it must exist. * This may be used if the application guarantees or does not care about the existence check. */ public void assumeExistenceForDoesExist() { getDoesExistQuery().assumeExistenceForDoesExist(); }
/** * PUBLIC: * Perform does exist check on the database */ public void checkDatabaseForDoesExist() { getDoesExistQuery().checkDatabaseForDoesExist(); }
/** * PUBLIC: * Assume that the object does not exist. This may be used if the application guarantees or * does not care about the existence check. This will always force an insert to be called. */ public void assumeNonExistenceForDoesExist() { getDoesExistQuery().assumeNonExistenceForDoesExist(); }
/** * PUBLIC: * Default behavior. * Assume that if the objects primary key does not include null and it * is in the cache, then is must exist. */ public void checkCacheForDoesExist() { getDoesExistQuery().checkCacheForDoesExist(); }
/** * ADVANCED: * Set the receiver's does exist call. * This allows the user to override the does exist operation. */ public void setDoesExistCall(Call call) { if (call == null) { return; } getDoesExistQuery().setCall(call); }
/** * ADVANCED: * Set the receiver's does exist SQL string. * This allows the user to override the SQL generated by TopLink, with there own SQL or procedure call. * The arguments are translated from the fields of the source row, through replacing the field names marked by '#' * with the values for those fields. * This must return null if the object does not exist, otherwise return a database row. * <p> * Example, "select EMPLOYEE_ID from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID". */ public void setDoesExistSQLString(String sqlString) { if (sqlString == null) { return; } getDoesExistQuery().setSQLString(sqlString); getDoesExistQuery().checkDatabaseForDoesExist(); }
/** * INTERNAL: * This method is explicitly used by the Builder only. */ public String getExistenceCheck() { if (getDoesExistQuery().shouldAssumeExistenceForDoesExist()) { return "Assume existence"; } else if (getDoesExistQuery().shouldAssumeNonExistenceForDoesExist()) { return "Assume non-existence"; } else if (getDoesExistQuery().shouldCheckCacheForDoesExist()) { return "Check cache"; } else if (getDoesExistQuery().shouldCheckDatabaseForDoesExist()) { return "Check database"; } else { // Default. return "Check cache"; } }
/** * INTERNAL: */ public boolean checkForUnregisteredExistingObject(Object object) { ClassDescriptor descriptor = getDescriptor(object.getClass()); Vector primaryKey = descriptor.getObjectBuilder().extractPrimaryKeyFromObject(object, this); DoesExistQuery existQuery = descriptor.getQueryManager().getDoesExistQuery(); existQuery = (DoesExistQuery)existQuery.clone(); existQuery.setObject(object); existQuery.setPrimaryKey(primaryKey); existQuery.setDescriptor(descriptor); existQuery.setCheckCacheFirst(true); if (((Boolean)executeQuery(existQuery)).booleanValue()) { return true; } else { return false; } }
manager.setDoesExistQuery((DoesExistQuery)getDoesExistQuery().clone()); if (getReadAllQuery() != null) { manager.setReadAllQuery((ReadAllQuery)getReadAllQuery().clone());
return null; DoesExistQuery existQuery = descriptor.getQueryManager().getDoesExistQuery();
DoesExistQuery existQuery = descriptor.getQueryManager().getDoesExistQuery(); existQuery = (DoesExistQuery)existQuery.clone(); existQuery.setObject(newObject);
setReadAllQuery((ReadAllQuery)parentQueryManager.getReadAllQuery().clone()); if ((!getDoesExistQuery().isUserDefined()) && getDoesExistQuery().shouldCheckCacheForDoesExist()) { setDoesExistQuery(((DoesExistQuery)parentQueryManager.getDoesExistQuery().clone()));
/** * INTERNAL: * Return if the object exists on the database or not. * This first checks existence in the chache, then on the database. */ protected boolean doesObjectExist() { boolean doesExist; if (getSession().isUnitOfWork()) { doesExist = !((UnitOfWorkImpl)getSession()).isCloneNewObject(getObject()); if (doesExist) { doesExist = ((UnitOfWorkImpl)getSession()).isObjectRegistered(getObject()); } } else { //Initialize does exist query DoesExistQuery existQuery = (DoesExistQuery)getDescriptor().getQueryManager().getDoesExistQuery().clone(); existQuery.setObject(getObject()); existQuery.setPrimaryKey(getPrimaryKey()); existQuery.setDescriptor(getDescriptor()); existQuery.setTranslationRow(getTranslationRow()); doesExist = ((Boolean)getSession().executeQuery(existQuery)).booleanValue(); } return doesExist; }
/** * INTERNAL: * Validate that the descriptor's non-mapping attribute are defined correctly. */ protected void selfValidationBeforeInitialization(AbstractSession session) throws DescriptorException { if (isChildDescriptor()) { ClassDescriptor parentDescriptor = session.getDescriptor(getInheritancePolicy().getParentClass()); if (parentDescriptor == null) { session.getIntegrityChecker().handleError(DescriptorException.parentDescriptorNotSpecified(getInheritancePolicy().getParentClass().getName(), this)); } } else { if (getTables().isEmpty() && (!isAggregateDescriptor())) { session.getIntegrityChecker().handleError(DescriptorException.tableNotSpecified(this)); } } if (!isChildDescriptor() && !isAggregateDescriptor()) { if (getPrimaryKeyFieldNames().isEmpty()) { session.getIntegrityChecker().handleError(DescriptorException.primaryKeyFieldsNotSepcified(this)); } } if ((getIdentityMapClass() == ClassConstants.NoIdentityMap_Class) && (getQueryManager().getDoesExistQuery().shouldCheckCacheForDoesExist())) { session.getIntegrityChecker().handleError(DescriptorException.identityMapNotSpecified(this)); } if (((getSequenceNumberName() != null) && (getSequenceNumberField() == null)) || ((getSequenceNumberName() == null) && (getSequenceNumberField() != null))) { session.getIntegrityChecker().handleError(DescriptorException.sequenceNumberPropertyNotSpecified(this)); } }
oracle.toplink.essentials.queryframework.DoesExistQuery existQuery = descriptor.getQueryManager().getDoesExistQuery();
if (registeredObject == null) { Vector primaryKey = descriptor.getObjectBuilder().extractPrimaryKeyFromObject(toBeDeleted, this); DoesExistQuery existQuery = descriptor.getQueryManager().getDoesExistQuery(); existQuery = (DoesExistQuery)existQuery.clone(); existQuery.setObject(toBeDeleted);