/** * Convenience method */ protected ObjectBuilder getObjectBuilderForClass(Class javaClass, AbstractSession session) { return getReferenceDescriptor(javaClass, session).getObjectBuilder(); }
/** * Convenience method */ protected ObjectBuilder getObjectBuilder(Object attributeValue, AbstractSession session) { return getReferenceDescriptor(attributeValue, session).getObjectBuilder(); }
/** * By default create a new instance. */ public Object buildWorkingCopyCloneFromRow(Record row, ObjectBuildingQuery query) throws DescriptorException { return getDescriptor().getObjectBuilder().buildNewInstance(); }
/** * INTERNAL: * Extract primary key from a row * @param DatabaseRow to extract primary key from * @param Class * @return Vector primary key */ protected Vector extractPrimaryKeyFromRow(Record rowContainingPrimaryKey, Class theClass) { return this.session.getDescriptor(theClass).getObjectBuilder().extractPrimaryKeyFromRow((AbstractRecord)rowContainingPrimaryKey, this.session); }
/** * INTERNAL: * Unwrap the object if required. * This is used for the wrapper policy support and EJB. */ public Object unwrapObject(Object proxy) { return getDescriptor(proxy).getObjectBuilder().unwrapObject(proxy, this); }
/** * INTERNAL: */ protected Vector getPrimaryKeyForObject(Object object, AbstractSession session) { return getReferenceDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(object, session); }
/** * INTERNAL: * Return the classification for the field contained in the mapping. * This is used to convert the row value to a consistent Java value. */ public Class getFieldClassification(DatabaseField fieldToClassify) { DatabaseMapping mapping = getReferenceDescriptor().getObjectBuilder().getMappingForField(fieldToClassify); if (mapping == null) { return null;// Means that the mapping is read-only } return mapping.getFieldClassification(fieldToClassify); }
/** * INTERNAL: * This method is used to revert an object within the unit of work * @param cloneMapping may not be the same as whats in the uow */ public void revertChanges(Object clone, ClassDescriptor descriptor, UnitOfWorkImpl uow, IdentityHashtable cloneMapping) { cloneMapping.put(clone, buildBackupClone(clone, descriptor.getObjectBuilder(), uow)); clearChanges(clone, uow, descriptor); }
/** * INTERNAL: * retrieves the lock value from the object. */ protected Object lockValueFromObject(Object domainObject) { return getDescriptor().getObjectBuilder().getBaseValueForField(getWriteLockField(), domainObject); }
/** * INTERNAL: * Called by CursoredStream to construct objects from rows. * Subclasses which build other results objects (ReportQuery, & PartialObjects) may override */ public Object buildObject(AbstractRecord row) { return getDescriptor().getObjectBuilder().buildObject(this, row, this.getJoinedAttributeManager()); }
/** * Get the object from the identity map which has the same identity information * as the given object. */ public Object getFromIdentityMap(Object object) { ClassDescriptor descriptor = getSession().getDescriptor(object); Vector primaryKey = descriptor.getObjectBuilder().extractPrimaryKeyFromObject(object, getSession()); return getFromIdentityMap(primaryKey, object.getClass(), descriptor); }
/** * INTERNAL: */ public DatabaseField getField() { if (!isAttribute()) { return null; } return getContainingDescriptor().getObjectBuilder().getFieldForQueryKeyName(getName()); }
/** * INTERNAL: * Iterate on the attribute value. * The value holder has already been processed. */ public void iterateOnRealAttributeValue(DescriptorIterator iterator, Object realAttributeValue) { // This may be wrapped as the caller in iterate on foreign reference does not unwrap as the type is generic. Object unwrappedAttributeValue = getReferenceDescriptor().getObjectBuilder().unwrapObject(realAttributeValue, iterator.getSession()); iterator.iterateReferenceObjectForMapping(unwrappedAttributeValue, this); }
/** * PUBLIC: * Return a new instance of the class registered in this unit of work. * This can be used to ensure that new objects are registered correctly. */ public Object newInstance(Class theClass) { //CR#2272 logDebugMessage(theClass, "new_instance"); ClassDescriptor descriptor = getDescriptor(theClass); Object newObject = descriptor.getObjectBuilder().buildNewInstance(); return registerObject(newObject); }
/** * Build the objects for the rows, and answer them * @exception DatabaseException - an error has occurred on the database */ public Object buildObjectsFromRows(Vector rows) throws DatabaseException { Object result = ((ReadAllQuery)getQuery()).getContainerPolicy().containerInstance(rows.size()); return getDescriptor().getObjectBuilder().buildObjectsInto((ReadAllQuery)getQuery(), rows, result); } ;
public void iterate(Object object) { if (!containsObjectInIdentityMap(IdentityMapAccessor.this.session.getDescriptor(object.getClass()).getObjectBuilder().extractPrimaryKeyFromObject(object, IdentityMapAccessor.this.getSession()), object.getClass())) { IdentityMapAccessor.this.session.log(SessionLog.FINEST, SessionLog.CACHE, "stack_of_visited_objects_that_refer_to_the_corrupt_object", getVisitedStack()); IdentityMapAccessor.this.session.log(SessionLog.FINER, SessionLog.CACHE, "corrupt_object_referenced_through_mapping", getCurrentMapping()); IdentityMapAccessor.this.session.log(SessionLog.FINER, SessionLog.CACHE, "corrupt_object", object); } } };
public DatabaseMapping getMapping() { if (getBaseExpression() == null) { return null; } ClassDescriptor aDescriptor = ((DataExpression)getBaseExpression()).getDescriptor(); if (aDescriptor == null) { return null; } return aDescriptor.getObjectBuilder().getMappingForAttributeName(getName()); }
/** * Return the appropriate delete statement */ protected SQLDeleteStatement buildDeleteStatement(DatabaseTable table) { SQLDeleteStatement deleteStatement = new SQLDeleteStatement(); Expression whereClause; whereClause = getDescriptor().getObjectBuilder().buildDeleteExpression(table, getTranslationRow()); deleteStatement.setWhereClause(whereClause); deleteStatement.setTable(table); deleteStatement.setTranslationRow(getTranslationRow()); return deleteStatement; }
/** * 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())); } }
/** * Return the appropriate update statement * @return SQLInsertStatement */ protected SQLUpdateStatement buildUpdateStatement(DatabaseTable table) { SQLUpdateStatement updateStatement = new SQLUpdateStatement(); updateStatement.setModifyRow(getModifyRow()); updateStatement.setTranslationRow(getTranslationRow()); updateStatement.setTable(table); updateStatement.setWhereClause(getDescriptor().getObjectBuilder().buildUpdateExpression(table, getTranslationRow(), getModifyRow())); return updateStatement; }