/** * INTERNAL: * Return the DatabaseField that represents the key in a DirectMapMapping. If the * keyMapping is not a DirectMapping, this will return null * @return */ public DatabaseField getDirectKeyField(CollectionMapping baseMapping){ if (((DatabaseMapping)keyMapping).isDirectToFieldMapping()){ return ((DirectToFieldMapping)keyMapping).getField(); } return null; }
/** * Reset field type to use BLOB/CLOB with type conversion mapping fix for 4k oracle thin driver bug. */ private void resetFieldTypeForLOB(DirectToFieldMapping mapping) { if (mapping.getFieldClassification().getName().equals("java.sql.Blob")) { //allow the platform to figure out what database field type gonna be used. //For example, Oracle9 will generate BLOB type, SQL Server generats IMAGE. getFieldDefFromDBField(mapping.getField(), false).setType(Byte[].class); } else if (mapping.getFieldClassification().getName().equals("java.sql.Clob")) { //allow the platform to figure out what database field type gonna be used. //For example, Oracle9 will generate CLOB type. SQL Server generats TEXT. getFieldDefFromDBField(mapping.getField(), false).setType(Character[].class); } }
/** * Reset field type to use BLOB/CLOB with type conversion mapping fix for 4k oracle thin driver bug. */ protected void resetFieldTypeForLOB(DirectToFieldMapping mapping) { if (mapping.getFieldClassification().getName().equals("java.sql.Blob")) { //allow the platform to figure out what database field type gonna be used. //For example, Oracle9 will generate BLOB type, SQL Server generats IMAGE. getFieldDefFromDBField(mapping.getField()).setType(Byte[].class); } else if (mapping.getFieldClassification().getName().equals("java.sql.Clob")) { //allow the platform to figure out what database field type gonna be used. //For example, Oracle9 will generate CLOB type. SQL Server generats TEXT. getFieldDefFromDBField(mapping.getField()).setType(Character[].class); } }
protected void writeValueIntoRow(AbstractRecord row, DatabaseField field, Object fieldValue) { row.add(getField(), fieldValue); } }
/** * Reset field type to use BLOB/CLOB with type conversion mapping fix for 4k oracle thin driver bug. */ protected void resetFieldTypeForLOB(DirectToFieldMapping mapping) { if (mapping.getFieldClassification().getName().equals("java.sql.Blob")) { //allow the platform to figure out what database field type gonna be used. //For example, Oracle9 will generate BLOB type, SQL Server generats IMAGE. getFieldDefFromDBField(mapping.getField()).setType(Byte[].class); } else if (mapping.getFieldClassification().getName().equals("java.sql.Clob")) { //allow the platform to figure out what database field type gonna be used. //For example, Oracle9 will generate CLOB type. SQL Server generats TEXT. getFieldDefFromDBField(mapping.getField()).setType(Character[].class); } }
protected void writeValueIntoRow(AbstractRecord row, DatabaseField field, Object fieldValue) { row.add(getField(), fieldValue); } }
@Override public void logDatabaseMapping(final DirectToFieldMapping databaseMapping, final Session session) { logFine(session, "\tmapping.attributeName : {0}", databaseMapping.getAttributeName()); logFine(session, "\tmapping.attributeClassification: {0}", databaseMapping.getAttributeClassification()); logFine(session, "\tmapping.field.name : {0}", databaseMapping.getField().getName()); logFine(session, "\tmapping.field.sqlType : {0}", databaseMapping.getField().getSqlType()); logFine(session, "\tmapping.field.typeName: {0}", databaseMapping.getField().getTypeName()); logFine(session, "\tmapping.field.columnDefinition : {0}", databaseMapping.getField().getColumnDefinition()); logFine(session, "\tmapping.fieldClassfication : {0}", databaseMapping.getFieldClassification()); }
protected void writeValueIntoRow(AbstractRecord row, DatabaseField field, Object fieldValue) { row.add(getField(), fieldValue); } }
@Override public void customizeConverter(final DirectToFieldMapping databaseMapping, final Session session) { if (hasEnumTypeConverter(databaseMapping)) { final EnumTypeConverter eclipseConverter = (EnumTypeConverter) databaseMapping.getConverter(); final Class enumClazz = eclipseConverter.getEnumClass(); logFine(session, "Set enum-converter to field {0} with class {1}", databaseMapping.getField().getName(), enumClazz.getName()); databaseMapping.setConverter( new org.zalando.jpa.eclipselink.customizer.databasemapping.support.EnumTypeConverter(enumClazz, databaseMapping.getField().getColumnDefinition())); } }
if (refMapping.isDirectToFieldMapping()) { DirectToFieldMapping refDirectMapping = (DirectToFieldMapping) refMapping; String refFieldName = refDirectMapping.getField().getName(); if (!mapping.containsKey(refFieldName)) { DatabaseField mappedField = refDirectMapping.getField().clone(); mappedField.setName(m.getAttributeName() + "_" + mappedField.getName()); mapping.put(refFieldName, mappedField);
@Override public void customizeColumnName(final String tableName, final DirectToFieldMapping databaseMapping, final Session session) { logDatabaseMapping(databaseMapping, session); String newFieldName = null; EntityFieldInspector<?> entityFieldInspector = FieldInspector.getFieldInspector(databaseMapping); if (shouldCreateBooleanFieldName(entityFieldInspector)) { newFieldName = NameUtils.buildBooleanFieldName(tableName, databaseMapping.getAttributeName()); } else if (!entityFieldInspector.isNameValueSet()) { // default newFieldName = NameUtils.buildFieldName(tableName, databaseMapping.getAttributeName()); } else if (entityFieldInspector.isNameValueSet()) { // column-annotation name value is set newFieldName = NameUtils.buildFieldName(tableName, databaseMapping.getField().getName()); } databaseMapping.getField().setName(newFieldName); logFine(session, "set new field-name to {0}", newFieldName); }