/** * PUBLIC: * The default value to substitute for database NULLs can be configured * on a per-class basis. * Example: login.setDefaultNullValue(long.class, new Long(0)) */ public void setDefaultNullValue(Class type, Object value) { getDatasourcePlatform().getConversionManager().setDefaultNullValue(type, value); }
public Class resolveClass(ObjectStreamClass classDesc) throws ClassNotFoundException, IOException { ConversionManager cm = m_session.getDatasourceLogin().getDatasourcePlatform().getConversionManager(); return (Class)cm.convertObject(classDesc.getName(), Class.class); } }
/** * ADVANCE: * This method returns the class type that this changeSet Represents. * This requires the session to reload the class on serialization. * @return java.lang.Class */ public Class getClassType(oracle.toplink.essentials.sessions.Session session) { if (classType == null) { classType = (Class)((AbstractSession)session).getDatasourcePlatform().getConversionManager().convertObject(getClassName(), ClassConstants.CLASS); } return classType; }
/** * INTERNAL: * Extract the foreign key value from the source row. */ protected Vector extractForeignKeyFromRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(); for (Iterator fieldEnum = getSourceToTargetKeyFields().keySet().iterator(); fieldEnum.hasNext();) { DatabaseField field = (DatabaseField)fieldEnum.next(); Object value = row.get(field); // Must ensure the classificatin to get a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(field)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
/** * INTERNAL: * Extract the primary key value from the source row. * Used for batch reading, most following same order and fields as in the mapping. */ protected Vector extractPrimaryKeyFromRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(getSourceKeyFields().size()); for (Enumeration fieldEnum = getSourceKeyFields().elements(); fieldEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)fieldEnum.nextElement(); Object value = row.get(field); // Must ensure the classificatin to get a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(field)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
/** * Build the row from the primary key values. */ public AbstractRecord buildRowFromPrimaryKeyValues(Vector key, AbstractSession session) { AbstractRecord databaseRow = createRecord(key.size()); int keySize = key.size(); for (int index = 0; index < keySize; index++) { DatabaseField field = (DatabaseField)getDescriptor().getPrimaryKeyFields().get(index); Object value = key.elementAt(index); value = session.getPlatform(getDescriptor().getJavaClass()).getConversionManager().convertObject(value, field.getType()); databaseRow.put(field, value); } return databaseRow; }
/** * INTERNAL: * Extract the primary key value from the source row. * Used for batch reading, most following same order and fields as in the mapping. */ protected Vector extractPrimaryKeyFromRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(getSourceKeyFields().size()); for (Enumeration fieldEnum = getSourceKeyFields().elements(); fieldEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)fieldEnum.nextElement(); Object value = row.get(field); // Must ensure the classificatin to get a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(field)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
/** * INTERNAL: * Extract the primary key value from the source row. * Used for batch reading, most following same order and fields as in the mapping. */ protected Vector extractPrimaryKeyFromRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(getSourceKeyFields().size()); for (Enumeration fieldEnum = getSourceKeyFields().elements(); fieldEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)fieldEnum.nextElement(); Object value = row.get(field); // Must ensure the classificatin to get a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(field)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
/** * INTERNAL: * Extract the source primary key value from the target row. * Used for batch reading, most following same order and fields as in the mapping. */ protected Vector extractKeyFromTargetRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(getTargetForeignKeyFields().size()); for (int index = 0; index < getTargetForeignKeyFields().size(); index++) { DatabaseField targetField = (DatabaseField)getTargetForeignKeyFields().elementAt(index); DatabaseField sourceField = (DatabaseField)getSourceKeyFields().elementAt(index); Object value = row.get(targetField); // Must ensure the classificatin to get a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(sourceField)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
/** * INTERNAL: * Extract the source primary key value from the relation row. * Used for batch reading, most following same order and fields as in the mapping. */ protected Vector extractKeyFromRelationRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(getSourceRelationKeyFields().size()); for (int index = 0; index < getSourceRelationKeyFields().size(); index++) { DatabaseField relationField = (DatabaseField)getSourceRelationKeyFields().elementAt(index); DatabaseField sourceField = (DatabaseField)getSourceKeyFields().elementAt(index); Object value = row.get(relationField); // Must ensure the classificatin to get a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(sourceField)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
/** * INTERNAL: * Extract the source primary key value from the reference direct row. * Used for batch reading, most following same order and fields as in the mapping. */ protected Vector extractKeyFromReferenceRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(getReferenceKeyFields().size()); for (int index = 0; index < getReferenceKeyFields().size(); index++) { DatabaseField relationField = (DatabaseField)getReferenceKeyFields().elementAt(index); DatabaseField sourceField = (DatabaseField)getSourceKeyFields().elementAt(index); Object value = row.get(relationField); // Must ensure the classificatin to get a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(sourceField)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
public DatabaseQuery processEjbQLQuery(Session session){ ClassLoader classloader = session.getDatasourcePlatform().getConversionManager().getLoader(); DatabaseQuery ejbquery = EJBQueryImpl.buildEJBQLDatabaseQuery( this.getName(), ejbQLString, flushOnExecute, session, hints, classloader); ejbquery.setName(this.getName()); return ejbquery; }
/** * Convert the given object to the class represented by the given temporal type. * @return an object represting the given TemporalType */ protected Object convertTemporalType(Object value, TemporalType type) { ConversionManager conversionManager = ((oracle.toplink.essentials.internal.sessions.AbstractSession)getEntityManager().getActiveSession()).getDatasourcePlatform().getConversionManager(); if (type == TemporalType.TIME) { return conversionManager.convertObject(value, ClassConstants.TIME); } else if (type == TemporalType.TIMESTAMP) { return conversionManager.convertObject(value, ClassConstants.TIMESTAMP); } else if (type == TemporalType.DATE) { return conversionManager.convertObject(value, ClassConstants.SQLDATE); } return value; }
/** * INTERNAL: * Returns the corresponding attribute value for the specified field value. */ public Object convertDataValueToObjectValue(Object fieldValue, Session session) { Object attributeValue = null; if (fieldValue == null) { attributeValue = getFieldToAttributeValues().get(Helper.getNullWrapper()); } else { try { fieldValue = ((AbstractSession)session).getDatasourcePlatform().getConversionManager().convertObject(fieldValue, getFieldClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } attributeValue = getFieldToAttributeValues().get(fieldValue); //Custom function. Create an operator for it. if (attributeValue == null) { attributeValue = ExpressionOperator.simpleFunction(0, (String)fieldValue); } } return attributeValue; } }
/** * INTERNAL: * Handler for the descriptor post build event. * Convert the key and values to their appropriate type. */ public void postBuild(DescriptorEvent event) { setKey(event.getSession().getDatasourceLogin().getDatasourcePlatform().getConversionManager().convertObject(getKey(), getKeyType())); setValue(event.getSession().getDatasourceLogin().getDatasourcePlatform().getConversionManager().convertObject(getValue(), getValueType())); }
if (shouldCheckClassLoader && (session != null) && !session.getDatasourcePlatform().getConversionManager().getLoader().equals(objectClassLoader)) {
/** * INTERNAL: * Returns the corresponding attribute value for the specified field value. */ public Object convertDataValueToObjectValue(Object fieldValue, Session session) { Object attributeValue = null; if (fieldValue == null) { attributeValue = getFieldToAttributeValues().get(Helper.getNullWrapper()); } else { try { fieldValue = ((AbstractSession)session).getDatasourcePlatform().getConversionManager().convertObject(fieldValue, getFieldClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } attributeValue = getFieldToAttributeValues().get(fieldValue); if (attributeValue == null) { if (getDefaultAttributeValue() != null) { attributeValue = getDefaultAttributeValue(); } else { // CR#3779 throw DescriptorException.noFieldValueConversionToAttributeValueProvided(fieldValue, getMapping().getField(), getMapping()); } } } return attributeValue; }
Object classFieldValue = session.getDatasourcePlatform().getConversionManager().convertObject(rowFromDatabase.get(getClassIndicatorField()), getClassIndicatorField().getType());
setClassIndicatorMapping(getParentDescriptor().getInheritancePolicy().getClassIndicatorMapping(session.getDatasourcePlatform().getConversionManager())); setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator()); } else if (!getClassIndicatorMapping(session.getDatasourcePlatform().getConversionManager()).isEmpty()) { Class type = null; Iterator fieldValuesEnum = getClassIndicatorMapping(session.getDatasourcePlatform().getConversionManager()).values().iterator(); while (fieldValuesEnum.hasNext() && (type == null)) { Object value = fieldValuesEnum.next();
session.getDatasourcePlatform().getConversionManager().setLoader(realClassLoader); state = STATE_DEPLOYED; } catch (RuntimeException ex) {