/** * Build a selection query for the primary key values. */ protected ReadObjectQuery getReadObjectQuery(Class referenceClass, Object primaryKey, Map properties) { ReadObjectQuery query = getReadObjectQuery(properties); query.setReferenceClass(referenceClass); query.setSelectionId(primaryKey); return query; }
/** * PUBLIC: * Read the first instance of the class from the database. * This operation can be customized through using a ReadObjectQuery, * or through also passing in a selection criteria. * * @see ReadObjectQuery * @see #readAllObjects(Class, Expression) */ public Object readObject(Class domainClass) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database. * This operation can be customized through using a ReadObjectQuery, * or through also passing in a selection criteria. * * @see ReadObjectQuery * @see #readAllObjects(Class, Expression) */ public Object readObject(Class domainClass) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database. * This operation can be customized through using a ReadObjectQuery, * or through also passing in a selection criteria. * * @see ReadObjectQuery * @see #readAllObjects(Class, Expression) */ @Override public Object readObject(Class domainClass) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database matching the given expression. * This operation can be customized through using a ReadObjectQuery. * * @see ReadObjectQuery */ public Object readObject(Class domainClass, Expression expression) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setSelectionCriteria(expression); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database matching the given expression. * This operation can be customized through using a ReadObjectQuery. * * @see ReadObjectQuery */ public Object readObject(Class domainClass, Expression expression) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setSelectionCriteria(expression); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database returned through execution the Call string. * The Call can be an SQLCall or JPQLCall. * * example: session.readObject(Employee.class, new SQLCall("SELECT * FROM EMPLOYEE")); * @see SQLCall * @see JPQLCall */ @Override public Object readObject(Class domainClass, Call aCall) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setCall(aCall); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database returned through execution the Call string. * The Call can be an SQLCall or JPQLCall. * * example: session.readObject(Employee.class, new SQLCall("SELECT * FROM EMPLOYEE")); * @see SQLCall * @see JPQLCall */ public Object readObject(Class domainClass, Call aCall) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setCall(aCall); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database matching the given expression. * This operation can be customized through using a ReadObjectQuery. * * @see ReadObjectQuery */ @Override public Object readObject(Class domainClass, Expression expression) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setSelectionCriteria(expression); query.setIsExecutionClone(true); return executeQuery(query); }
/** * INTERNAL: Generates the read stored procedure for this descriptor */ protected StoredProcedureDefinition generateReadStoredProcedure(ClassDescriptor descriptor) { ReadObjectQuery readQuery = new ReadObjectQuery(); readQuery.setDescriptor(descriptor); readQuery.setReferenceClass(descriptor.getJavaClass()); return generateObjectStoredProcedure(readQuery, descriptor.getPrimaryKeyFields(), "READ_"); }
/** * PUBLIC: * Read the first instance of the class from the database returned through execution the Call string. * The Call can be an SQLCall or JPQLCall. * * example: session.readObject(Employee.class, new SQLCall("SELECT * FROM EMPLOYEE")); * @see SQLCall * @see JPQLCall */ public Object readObject(Class domainClass, Call aCall) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setCall(aCall); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database return through execution the SQL string. * The SQL string must be a valid SQL select statement or selecting stored procedure call. * This operation can be customized through using a ReadObjectQuery. * Warning: Allowing an unverified SQL string to be passed into this * method makes your application vulnerable to SQL injection attacks. * * @see ReadObjectQuery */ public Object readObject(Class domainClass, String sqlString) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setSQLString(sqlString); query.setIsExecutionClone(true); return executeQuery(query); }
/** * PUBLIC: * Read the first instance of the class from the database return through execution the SQL string. * The SQL string must be a valid SQL select statement or selecting stored procedure call. * This operation can be customized through using a ReadObjectQuery. * Warning: Allowing an unverified SQL string to be passed into this * method makes your application vulnerable to SQL injection attacks. * * @see ReadObjectQuery */ public Object readObject(Class domainClass, String sqlString) throws DatabaseException { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(domainClass); query.setSQLString(sqlString); query.setIsExecutionClone(true); return executeQuery(query); }
/** * INTERNAL: Generates the read stored procedure for this descriptor */ protected StoredProcedureDefinition generateReadStoredProcedure(ClassDescriptor descriptor) { ReadObjectQuery readQuery = new ReadObjectQuery(); readQuery.setDescriptor(descriptor); readQuery.setReferenceClass(descriptor.getJavaClass()); return generateObjectStoredProcedure(readQuery, descriptor.getPrimaryKeyFields(), "READ_"); }
/** * INTERNAL: Generates the read stored procedure for this descriptor */ protected StoredProcedureDefinition generateReadStoredProcedure(ClassDescriptor descriptor) { ReadObjectQuery readQuery = new ReadObjectQuery(); readQuery.setDescriptor(descriptor); readQuery.setReferenceClass(descriptor.getJavaClass()); return generateObjectStoredProcedure(readQuery, descriptor.getPrimaryKeyFields(), "READ_"); }
/** * INTERNAL: * Check if the object is invalid and refresh it. * This is used to ensure that no invalid objects are registered. */ public void checkAndRefreshInvalidObject(Object object, CacheKey cacheKey, ClassDescriptor descriptor) { if (isConsideredInvalid(object, cacheKey, descriptor)) { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(object.getClass()); query.setSelectionId(cacheKey.getKey()); query.refreshIdentityMapResult(); query.setIsExecutionClone(true); this.executeQuery(query); } }
/** * INTERNAL: * Select one object of any concrete subclass. */ protected Object selectOneObject(ReadObjectQuery query) throws DescriptorException { ReadObjectQuery concreteQuery = (ReadObjectQuery) query.clone(); Class javaClass = descriptor.getJavaClass(); concreteQuery.setReferenceClass(javaClass); concreteQuery.setDescriptor(descriptor); return query.getSession().executeQuery(concreteQuery, concreteQuery.getTranslationRow()); }
/** * INTERNAL: * This method is used to load a relationship from a list of PKs. * This list may be available if the relationship has been cached. */ @Override public Object valueFromPKList(Object[] pks, AbstractRecord foreignKeys, AbstractSession session) { if (pks.length == 0 || pks[0] == null) return null; ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(getReferenceClass()); query.setSelectionId(pks[0]); query.setIsExecutionClone(true); query.setSession(session); return session.executeQuery(query); }
/** * INTERNAL: * This method is used to load a relationship from a list of PKs. * This list may be available if the relationship has been cached. */ @Override public Object valueFromPKList(Object[] pks, AbstractRecord foreignKeys, AbstractSession session) { if (pks.length == 0 || pks[0] == null) return null; ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(getReferenceClass()); query.setSelectionId(pks[0]); query.setIsExecutionClone(true); query.setSession(session); return session.executeQuery(query); }
/** * INTERNAL * Return true if the refresh should refresh on this mapping or not. */ protected ReadObjectQuery buildCascadeQuery(MergeManager mergeManager) { ReadObjectQuery query = new ReadObjectQuery(); if (this.mapping.getReferenceDescriptor() != null) { query.setReferenceClass(this.mapping.getReferenceDescriptor().getJavaClass()); } if (mergeManager.shouldCascadeAllParts()) { query.cascadeAllParts(); query.refreshIdentityMapResult(); } if (mergeManager.shouldCascadePrivateParts() && getForeignReferenceMapping().isPrivateOwned()) { query.cascadePrivateParts(); query.refreshIdentityMapResult(); } return query; }