/** * INTERNAL: * Returns the value for the mapping directly from the result-set. * PERF: Used for optimized object building. */ @Override public Object valueFromResultSet(ResultSet resultSet, ObjectBuildingQuery query, AbstractSession session, DatabaseAccessor accessor, ResultSetMetaData metaData, int columnNumber, DatabasePlatform platform) throws SQLException { if (this.attributeObjectClassification == ClassConstants.STRING) { Object val; if(platform.shouldUseGetSetNString()){ val = resultSet.getNString(columnNumber); }else { val = resultSet.getString(columnNumber); } return getObjectValueWithoutClassCheck(val, session); } else if (this.attributeObjectClassification == ClassConstants.LONG) { return getObjectValueWithoutClassCheck(resultSet.getLong(columnNumber), session); } else if (this.attributeObjectClassification == ClassConstants.INTEGER) { return getObjectValueWithoutClassCheck(resultSet.getInt(columnNumber), session); } Object fieldValue = accessor.getObject(resultSet, getField(), metaData, columnNumber, platform, true, session); return getObjectValue(fieldValue, session); }
/** * INTERNAL * Called when a DatabaseMapping is used to map the key in a collection. Returns the key. */ public Object createMapComponentFromRow(AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected) { Object key = dbRow.get(getField()); key = getObjectValue(key, session); return key; }
/** * INTERNAL * Called when a DatabaseMapping is used to map the key in a collection. Returns the key. */ public Object createMapComponentFromRow(AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected) { Object key = dbRow.get(getField()); key = getObjectValue(key, session); return key; }
/** * INTERNAL: * Returns the value for the mapping directly from the result-set. * PERF: Used for optimized object building. */ @Override public Object valueFromResultSet(ResultSet resultSet, ObjectBuildingQuery query, AbstractSession session, DatabaseAccessor accessor, ResultSetMetaData metaData, int columnNumber, DatabasePlatform platform) throws SQLException { if (this.attributeObjectClassification == ClassConstants.STRING) { Object val; if(platform.shouldUseGetSetNString()){ val = resultSet.getNString(columnNumber); }else { val = resultSet.getString(columnNumber); } return getObjectValueWithoutClassCheck(val, session); } else if (this.attributeObjectClassification == ClassConstants.LONG) { return getObjectValueWithoutClassCheck(resultSet.getLong(columnNumber), session); } else if (this.attributeObjectClassification == ClassConstants.INTEGER) { return getObjectValueWithoutClassCheck(resultSet.getInt(columnNumber), session); } Object fieldValue = accessor.getObject(resultSet, getField(), metaData, columnNumber, platform, true, session); return getObjectValue(fieldValue, session); }
newAttributeValue = ((Calendar)attributeValue).clone(); } else { newAttributeValue = getObjectValue(getFieldValue(attributeValue, session), session);
newAttributeValue = ((Calendar)attributeValue).clone(); } else { newAttributeValue = getObjectValue(getFieldValue(attributeValue, session), session);
/** * INTERNAL: * Return the mapping's attribute value from the row. * The execution session is passed for the case of building a UnitOfWork clone * directly from a row, the session set in the query will not know which platform to use * for converting the value. Allows the correct session to be passed in. */ @Override public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed) { if (this.descriptor.getCachePolicy().isProtectedIsolation()) { if (this.isCacheable && isTargetProtected && cacheKey != null && cacheKey.getInvalidationState() != CacheKey.CACHE_KEY_INVALID) { Object cached = cacheKey.getObject(); if (cached != null) { if (wasCacheUsed != null){ wasCacheUsed[0] = Boolean.TRUE; } Object attributeValue = getAttributeValueFromObject(cached); return buildCloneValue(attributeValue, executionSession); } } } if (row.hasSopObject()) { return getAttributeValueFromObject(row.getSopObject()); } // PERF: Direct variable access. Object fieldValue = row.get(getField()); Object attributeValue = getObjectValue(fieldValue, executionSession); return attributeValue; }
/** * INTERNAL: * Return the mapping's attribute value from the row. * The execution session is passed for the case of building a UnitOfWork clone * directly from a row, the session set in the query will not know which platform to use * for converting the value. Allows the correct session to be passed in. */ public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed, boolean lookupField) { if (this.descriptor.getCachePolicy().isProtectedIsolation()) { if (this.isCacheable && isTargetProtected && cacheKey != null && cacheKey.getInvalidationState() != CacheKey.CACHE_KEY_INVALID) { Object cached = cacheKey.getObject(); if (cached != null) { if (wasCacheUsed != null){ wasCacheUsed[0] = Boolean.TRUE; } Object attributeValue = getAttributeValueFromObject(cached); return buildCloneValue(attributeValue, executionSession); } } } if (row.hasSopObject()) { return getAttributeValueFromObject(row.getSopObject()); } // PERF: Direct variable access. Object fieldValue = row.get(getField(), lookupField); Object attributeValue = getObjectValue(fieldValue, executionSession); return attributeValue; } //cuba end
/** * INTERNAL: * Used to update a changeRecord that is stored in the CHangeSet with a new value. */ public void updateChangeRecordForAttribute(DatabaseMapping mapping, Object value, AbstractSession session, Object oldValue) { String attributeName = mapping.getAttributeName(); ChangeRecord changeRecord = (ChangeRecord)getChangesForAttributeNamed(attributeName); // bug 2641228 always ensure that we convert the value to the correct type if (mapping.isDirectToFieldMapping()) { value = ((AbstractDirectMapping)mapping).getObjectValue(value, session); } if (changeRecord != null) { changeRecord.updateChangeRecordWithNewValue(value); } else if (mapping.isDirectToFieldMapping()) { // If it is direct to field then this is most likely the result of a forced update and // we will need to merge this object. changeRecord = new DirectToFieldChangeRecord(this); changeRecord.setAttribute(attributeName); changeRecord.setMapping(mapping); ((DirectToFieldChangeRecord)changeRecord).setNewValue(value); ((DirectToFieldChangeRecord)changeRecord).setOldValue(oldValue); this.addChange(changeRecord); } }
/** * INTERNAL: * Used to update a changeRecord that is stored in the CHangeSet with a new value. */ public void updateChangeRecordForAttribute(DatabaseMapping mapping, Object value, AbstractSession session, Object oldValue) { String attributeName = mapping.getAttributeName(); ChangeRecord changeRecord = (ChangeRecord)getChangesForAttributeNamed(attributeName); // bug 2641228 always ensure that we convert the value to the correct type if (mapping.isDirectToFieldMapping()) { value = ((AbstractDirectMapping)mapping).getObjectValue(value, session); } if (changeRecord != null) { changeRecord.updateChangeRecordWithNewValue(value); } else if (mapping.isDirectToFieldMapping()) { // If it is direct to field then this is most likely the result of a forced update and // we will need to merge this object. changeRecord = new DirectToFieldChangeRecord(this); changeRecord.setAttribute(attributeName); changeRecord.setMapping(mapping); ((DirectToFieldChangeRecord)changeRecord).setNewValue(value); ((DirectToFieldChangeRecord)changeRecord).setOldValue(oldValue); this.addChange(changeRecord); } }
Object convertedLockValue = this.lockMapping.getObjectValue(lockValue, session); if (objectChangeSet != null && (!objectChangeSet.isNew() || query.getDescriptor().shouldUseFullChangeSetsForNewObjects())) { Object oldValue = this.lockMapping.getAttributeValueFromObject(object);
Object convertedLockValue = this.lockMapping.getObjectValue(lockValue, session); if (objectChangeSet != null && (!objectChangeSet.isNew() || query.getDescriptor().shouldUseFullChangeSetsForNewObjects())) { Object oldValue = this.lockMapping.getAttributeValueFromObject(object);
Object convertedSequenceValue = null; if (this.sequenceMapping != null) { convertedSequenceValue = this.sequenceMapping.getObjectValue(sequenceValue, writeSession); this.sequenceMapping.setAttributeValueInObject(object, convertedSequenceValue); } else {
Object convertedSequenceValue = null; if (this.sequenceMapping != null) { convertedSequenceValue = this.sequenceMapping.getObjectValue(sequenceValue, writeSession); this.sequenceMapping.setAttributeValueInObject(object, convertedSequenceValue); } else {