use of org.eclipse.persistence.mappings.converters.SerializedObjectConverter in project eclipselink by eclipse-ee4j.
the class DefaultTableGenerator method postInitTableSchema.
/**
* Build additional table/field definitions for the descriptor, like relation table
* and direct-collection, direct-map table, as well as reset LOB type for serialized
* object mapping and type conversion mapping for LOB usage
*/
protected void postInitTableSchema(ClassDescriptor descriptor) {
for (DatabaseMapping mapping : descriptor.getMappings()) {
if (descriptor.isChildDescriptor() && descriptor.getInheritancePolicy().getParentDescriptor().getMappingForAttributeName(mapping.getAttributeName()) != null) {
// times for the same table.
continue;
} else if (mapping.isManyToManyMapping()) {
buildRelationTableDefinition((ManyToManyMapping) mapping, ((ManyToManyMapping) mapping).getRelationTableMechanism(), ((ManyToManyMapping) mapping).getListOrderField(), mapping.getContainerPolicy());
} else if (mapping.isDirectCollectionMapping()) {
buildDirectCollectionTableDefinition((DirectCollectionMapping) mapping, descriptor);
} else if (mapping.isDirectToFieldMapping()) {
Converter converter = ((DirectToFieldMapping) mapping).getConverter();
if (converter != null) {
if (converter instanceof TypeConversionConverter) {
resetFieldTypeForLOB((DirectToFieldMapping) mapping);
}
if (converter instanceof SerializedObjectConverter) {
// serialized object mapping field should be BLOB/IMAGE
getFieldDefFromDBField(mapping.getField()).setType(((SerializedObjectConverter) converter).getSerializer().getType());
}
}
} else if (mapping.isAggregateCollectionMapping()) {
// need to figure out the target foreign key field and add it into the aggregate target table
createAggregateTargetTable((AggregateCollectionMapping) mapping);
} else if (mapping.isForeignReferenceMapping()) {
if (mapping.isOneToOneMapping()) {
RelationTableMechanism relationTableMechanism = ((OneToOneMapping) mapping).getRelationTableMechanism();
if (relationTableMechanism == null) {
addForeignKeyFieldToSourceTargetTable((OneToOneMapping) mapping);
} else {
buildRelationTableDefinition((OneToOneMapping) mapping, relationTableMechanism, null, null);
}
} else if (mapping.isOneToManyMapping()) {
addForeignKeyFieldToSourceTargetTable((OneToManyMapping) mapping);
TableDefinition targTblDef = getTableDefFromDBTable(mapping.getReferenceDescriptor().getDefaultTable());
addFieldsForMappedKeyMapContainerPolicy(mapping.getContainerPolicy(), targTblDef);
}
} else if (mapping.isTransformationMapping()) {
resetTransformedFieldType((TransformationMapping) mapping);
} else if (mapping.isAggregateObjectMapping()) {
postInitTableSchema(mapping.getReferenceDescriptor());
}
}
processAdditionalTablePkFields(descriptor);
}
use of org.eclipse.persistence.mappings.converters.SerializedObjectConverter in project eclipselink by eclipse-ee4j.
the class LobMetadata method process.
/**
* INTERNAL:
* Every converter needs to be able to process themselves.
*/
@Override
public void process(DatabaseMapping mapping, MappingAccessor accessor, MetadataClass referenceClass, boolean isForMapKey) {
// referenceClass type.
if (isValidClobType(referenceClass)) {
setFieldClassification(mapping, java.sql.Clob.class, isForMapKey);
setConverter(mapping, new TypeConversionConverter(mapping), isForMapKey);
} else if (isValidBlobType(referenceClass)) {
setFieldClassification(mapping, java.sql.Blob.class, isForMapKey);
setConverter(mapping, new TypeConversionConverter(mapping), isForMapKey);
} else if (referenceClass.extendsInterface(Serializable.class)) {
setFieldClassification(mapping, java.sql.Blob.class, isForMapKey);
setConverter(mapping, new SerializedObjectConverter(mapping), isForMapKey);
} else {
// The referenceClass is neither a valid BLOB or CLOB attribute.
throw ValidationException.invalidTypeForLOBAttribute(mapping.getAttributeName(), referenceClass, accessor.getJavaClass());
}
}
Aggregations