/** * INTERNAL: * Convert to the field class. */ public Object convertObjectValueToDataValue(Object attributeValue, Session session) { try { return ((AbstractSession)session).getDatasourcePlatform().convertObject(attributeValue, getDataClass()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } }
/** * INTERNAL: * Convert to the field class. */ public Object convertObjectValueToDataValue(Object attributeValue, Session session) { try { return ((AbstractSession)session).getDatasourcePlatform().convertObject(attributeValue, getDataClass()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } }
/** * INTERNAL: * Return the value that should be stored in the identity map. If the value * is stored in the object, then return a null. */ public Object getValueToPutInCache(AbstractRecord row, AbstractSession session) { if (isStoredInCache()) { return session.getDatasourcePlatform().convertObject(row.get(getWriteLockField()), ClassConstants.TIMESTAMP); } else { return null; } }
/** * INTERNAL: * Convert to the field class. */ public Object convertObjectValueToDataValue(Object attributeValue, Session session) { try { return ((AbstractSession)session).getDatasourcePlatform().convertObject(attributeValue, getDataClass()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } }
/** * INTERNAL: * Return the value that should be stored in the identity map. If the value * is stored in the object, then return a null. */ public Object getValueToPutInCache(AbstractRecord row, AbstractSession session) { if (isStoredInCache()) { return session.getDatasourcePlatform().convertObject(row.get(getWriteLockField()), ClassConstants.TIMESTAMP); } else { return null; } }
/** * INTERNAL: * Return the value that should be stored in the identity map. If the value * is stored in the object, then return a null. */ public Object getValueToPutInCache(AbstractRecord row, AbstractSession session) { if (isStoredInCache()) { return session.getDatasourcePlatform().convertObject(row.get(getWriteLockField()), ClassConstants.TIMESTAMP); } else { return null; } }
/** * INTERNAL: * Return the implementor for a specified type */ protected Object getImplementorForType(Object type, AbstractSession session) { if (type == null) { return getTypeIndicatorTranslation().get(Helper.NULL_VALUE); } // Must ensure the type is the same, i.e. Integer != BigDecimal. try { type = session.getDatasourcePlatform().convertObject(type, getTypeField().getType()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } return getTypeIndicatorTranslation().get(type); }
/** * INTERNAL: * Convert the class name to a class, then create an instance of the class. */ public Object convertDataValueToObjectValue(Object fieldValue, Session session) { Object attributeValue = null; if (fieldValue != null) { Class attributeClass = (Class)((AbstractSession)session).getDatasourcePlatform().convertObject(fieldValue, ClassConstants.CLASS); try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { attributeValue = AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(attributeClass)); } catch (PrivilegedActionException exception) { throw ConversionException.couldNotBeConverted(fieldValue, attributeClass, exception.getException()); } } else { attributeValue = PrivilegedAccessHelper.newInstanceFromClass(attributeClass); } } catch (Exception exception) { throw ConversionException.couldNotBeConverted(fieldValue, attributeClass, exception); } } return attributeValue; }
/** * INTERNAL: * Return the implementor for a specified type */ protected Object getImplementorForType(Object type, AbstractSession session) { if (type == null) { return getTypeIndicatorTranslation().get(Helper.NULL_VALUE); } // Must ensure the type is the same, i.e. Integer != BigDecimal. try { type = session.getDatasourcePlatform().convertObject(type, getTypeField().getType()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } return getTypeIndicatorTranslation().get(type); }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { QName name = new QName(rootFragment.getNamespaceURI(), rootFragment.getLocalName()); if(mapping.isAbstractDirectMapping() && null == nestedConverter){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } if(null != nestedConverter) { dataValue = nestedConverter.convertDataValueToObjectValue(dataValue, session); } if(dataValue instanceof JAXBElement) { return dataValue; } if(null == declaredType) { return new JAXBElement(name, Object.class, scope, dataValue); } else { return new JAXBElement(name, declaredType, scope, dataValue); } }
/** * INTERNAL: * The field value must first be converted to the field type, then the attribute type. */ public Object convertDataValueToObjectValue(Object fieldValue, Session session) { Object attributeValue = fieldValue; if (attributeValue != null) { try { attributeValue = ((AbstractSession)session).getDatasourcePlatform().convertObject(attributeValue, getDataClass()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } try { attributeValue = ((AbstractSession)session).getDatasourcePlatform().convertObject(attributeValue, getObjectClass()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } } return attributeValue; }
/** * INTERNAL: * The field value must first be converted to the field type, then the attribute type. */ public Object convertDataValueToObjectValue(Object fieldValue, Session session) { Object attributeValue = fieldValue; if (attributeValue != null) { try { attributeValue = ((AbstractSession)session).getDatasourcePlatform().convertObject(attributeValue, getDataClass()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } try { attributeValue = ((AbstractSession)session).getDatasourcePlatform().convertObject(attributeValue, getObjectClass()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } } return attributeValue; }
/** * INTERNAL: * Provide for conversion of the passed object's value, based on the referenced field value. */ @Override public Object getFieldValue(Object value, AbstractSession session) { // Bug 418705 if (getField() != null && value != null && (value.getClass() != getField().getType()) && !(value instanceof Collection) && !(value instanceof Enum)) { try { return session.getDatasourcePlatform().convertObject(value, getField().getType()); } catch (ConversionException c) {} } return super.getFieldValue(value, session); }
/** * INTERNAL: * Return the implementor for a specified type */ protected Object getImplementorForType(Object type, AbstractSession session) { if (type == null) { return getTypeIndicatorTranslation().get(Helper.getNullWrapper()); } // Must ensure the type is the same, i.e. Integer != BigDecimal. try { type = session.getDatasourcePlatform().convertObject(type, getTypeField().getType()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } return getTypeIndicatorTranslation().get(type); }
/** * INTERNAL: * Compares the value from the row and from the object (or cache). * Will return true if the row is newer than the object. */ public boolean isNewerVersion(AbstractRecord databaseRow, Object domainObject, java.util.Vector primaryKey, AbstractSession session) { java.sql.Timestamp writeLockFieldValue; java.sql.Timestamp newWriteLockFieldValue = (java.sql.Timestamp)session.getDatasourcePlatform().convertObject(databaseRow.get(getWriteLockField()), ClassConstants.TIMESTAMP); if (isStoredInCache()) { writeLockFieldValue = (java.sql.Timestamp)session.getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, domainObject.getClass(), getDescriptor()); } else { writeLockFieldValue = (java.sql.Timestamp)lockValueFromObject(domainObject); } return isNewerVersion(newWriteLockFieldValue, writeLockFieldValue); }
/** * INTERNAL: * Compares the value from the row and from the object (or cache). * Will return true if the row is newer than the object. */ @Override public boolean isNewerVersion(AbstractRecord databaseRow, Object domainObject, Object primaryKey, AbstractSession session) { java.sql.Timestamp writeLockFieldValue; java.sql.Timestamp newWriteLockFieldValue = (java.sql.Timestamp)session.getDatasourcePlatform().convertObject(databaseRow.get(getWriteLockField()), ClassConstants.TIMESTAMP); if (isStoredInCache()) { writeLockFieldValue = (java.sql.Timestamp)session.getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, domainObject.getClass(), getDescriptor()); } else { writeLockFieldValue = (java.sql.Timestamp)lockValueFromObject(domainObject); } return isNewerVersion(newWriteLockFieldValue, writeLockFieldValue); }
/** * INTERNAL: * Compares the value from the row and from the object (or cache). * Will return true if the row is newer than the object. */ @Override public boolean isNewerVersion(AbstractRecord databaseRow, Object domainObject, Object primaryKey, AbstractSession session) { java.sql.Timestamp writeLockFieldValue; java.sql.Timestamp newWriteLockFieldValue = (java.sql.Timestamp)session.getDatasourcePlatform().convertObject(databaseRow.get(getWriteLockField()), ClassConstants.TIMESTAMP); if (isStoredInCache()) { writeLockFieldValue = (java.sql.Timestamp)session.getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, domainObject.getClass(), getDescriptor()); } else { writeLockFieldValue = (java.sql.Timestamp)lockValueFromObject(domainObject); } return isNewerVersion(newWriteLockFieldValue, writeLockFieldValue); }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }