/** 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()); }
protected Object readObjectFromRow(Session session, ClassDescriptor desc, Record row) { if (desc.hasInheritance()) { Class newClass = desc.getInheritancePolicy().classFromRow((DatabaseRecord) row, (AbstractSession) session); desc = session.getClassDescriptor(newClass); } Object object = desc.getObjectBuilder().buildNewInstance(); ReadObjectQuery query = new ReadObjectQuery(); query.setSession((AbstractSession) session); for (Enumeration mappings = desc.getMappings().elements(); mappings.hasMoreElements(); ) { DatabaseMapping mapping = (DatabaseMapping) mappings.nextElement(); mapping.readFromRowIntoObject( (DatabaseRecord) row, query.getJoinedAttributeManager(), object, null, query, query.getSession(), true); } return object; }