use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class MapCollectionsProject method buildAggregateEntity1MMapHolderDescriptor.
protected void buildAggregateEntity1MMapHolderDescriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
// SECTION: DESCRIPTOR
descriptor.setJavaClass(AggregateEntity1MMapHolder.class);
Vector vector = new Vector();
vector.addElement("AGG_ENT_1M_MAP_HOLDER");
descriptor.setTableNames(vector);
descriptor.addPrimaryKeyFieldName("AGG_ENT_1M_MAP_HOLDER.ID");
// SECTION: PROPERTIES
descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
descriptor.setExistenceChecking("Check cache");
descriptor.setIdentityMapSize(100);
descriptor.setSequenceNumberName("AGG_ENT_1M_MAP_HOLDER_ID");
descriptor.setSequenceNumberFieldName("ID");
// SECTION: DIRECTTOFIELDMAPPING
org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
directtofieldmapping.setAttributeName("id");
directtofieldmapping.setIsReadOnly(false);
directtofieldmapping.setGetMethodName("getId");
directtofieldmapping.setSetMethodName("setId");
directtofieldmapping.setFieldName("AGG_ENT_1M_MAP_HOLDER.ID");
descriptor.addMapping(directtofieldmapping);
OneToManyMapping mapMapping = new OneToManyMapping();
mapMapping.setAttributeName("aggregateToEntityMap");
mapMapping.setReferenceClass(AEOTMMapValue.class);
mapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
mapMapping.setGetMethodName("getAggregateToEntityMap");
mapMapping.setSetMethodName("setAggregateToEntityMap");
mapMapping.addTargetForeignKeyFieldName("AE_OM_ENT_MAP_VALUE.HOLDER_ID", "AGG_ENT_1M_MAP_HOLDER.ID");
AggregateObjectMapping keyMapping = new AggregateObjectMapping();
keyMapping.setReferenceClass(AggregateMapKey.class);
keyMapping.addFieldNameTranslation("AE_OM_ENT_MAP_VALUE.MAP_KEY", "key->DIRECT");
keyMapping.setDescriptor(descriptor);
MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
policy.setKeyMapping(keyMapping);
policy.setValueMapping(mapMapping);
mapMapping.setContainerPolicy(policy);
descriptor.addMapping(mapMapping);
addDescriptor(descriptor);
}
use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class MapCollectionsProject method buildAggregateAggregateMapHolderDescriptor.
protected void buildAggregateAggregateMapHolderDescriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
// SECTION: DESCRIPTOR
descriptor.setJavaClass(AggregateAggregateMapHolder.class);
Vector vector = new Vector();
vector.addElement("AGG_AGG_MAP_HOLDER");
descriptor.setTableNames(vector);
descriptor.addPrimaryKeyFieldName("AGG_AGG_MAP_HOLDER.ID");
// SECTION: PROPERTIES
descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
descriptor.setExistenceChecking("Check cache");
descriptor.setIdentityMapSize(100);
descriptor.setSequenceNumberName("AGG_AGG_MAP_HOLDER_ID");
descriptor.setSequenceNumberFieldName("ID");
// SECTION: DIRECTTOFIELDMAPPING
org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
directtofieldmapping.setAttributeName("id");
directtofieldmapping.setIsReadOnly(false);
directtofieldmapping.setGetMethodName("getId");
directtofieldmapping.setSetMethodName("setId");
directtofieldmapping.setFieldName("AGG_AGG_MAP_HOLDER.ID");
descriptor.addMapping(directtofieldmapping);
// SECTION: AGGREGATECOLLECTIONMAPPING
org.eclipse.persistence.mappings.AggregateCollectionMapping aggregatecollectionmapping = new org.eclipse.persistence.mappings.AggregateCollectionMapping();
aggregatecollectionmapping.setAttributeName("aggregateToAggregateMap");
aggregatecollectionmapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
aggregatecollectionmapping.setGetMethodName("getAggregateToAggregateMap");
aggregatecollectionmapping.setSetMethodName("setAggregateToAggregateMap");
aggregatecollectionmapping.setReferenceClass(AggregateMapKey.class);
aggregatecollectionmapping.addTargetForeignKeyFieldName("AGG_AGG_MAP_REL.HOLDER_ID", "AGG_AGG_MAP_HOLDER.ID");
aggregatecollectionmapping.addFieldNameTranslation("AGG_AGG_MAP_REL.MAP_VALUE", "key->DIRECT");
AggregateObjectMapping keyMapping = new AggregateObjectMapping();
keyMapping.setReferenceClass(AggregateMapKey.class);
keyMapping.addFieldNameTranslation("AGG_AGG_MAP_REL.MAP_KEY", "key->DIRECT");
keyMapping.setDescriptor(descriptor);
MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
policy.setKeyMapping(keyMapping);
policy.setValueMapping(aggregatecollectionmapping);
aggregatecollectionmapping.setContainerPolicy(policy);
descriptor.addMapping(aggregatecollectionmapping);
addDescriptor(descriptor);
}
use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class MapCollectionsProject method buildAggregateEntityU1MMapHolderDescriptor.
protected void buildAggregateEntityU1MMapHolderDescriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
// SECTION: DESCRIPTOR
descriptor.setJavaClass(AggregateEntityU1MMapHolder.class);
Vector vector = new Vector();
vector.addElement("AGG_ENT_U1M_MAP_HOLDER");
descriptor.setTableNames(vector);
descriptor.addPrimaryKeyFieldName("AGG_ENT_U1M_MAP_HOLDER.ID");
// SECTION: PROPERTIES
descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
descriptor.setExistenceChecking("Check cache");
descriptor.setIdentityMapSize(100);
descriptor.setSequenceNumberName("AGG_ENT_U1M_MAP_HOLDER_ID");
descriptor.setSequenceNumberFieldName("ID");
// SECTION: DIRECTTOFIELDMAPPING
org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
directtofieldmapping.setAttributeName("id");
directtofieldmapping.setIsReadOnly(false);
directtofieldmapping.setGetMethodName("getId");
directtofieldmapping.setSetMethodName("setId");
directtofieldmapping.setFieldName("AGG_ENT_U1M_MAP_HOLDER.ID");
descriptor.addMapping(directtofieldmapping);
UnidirectionalOneToManyMapping mapMapping = new UnidirectionalOneToManyMapping();
mapMapping.setAttributeName("aggregateToEntityMap");
mapMapping.setReferenceClass(EntityMapValue.class);
mapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
mapMapping.setGetMethodName("getAggregateToEntityMap");
mapMapping.setSetMethodName("setAggregateToEntityMap");
mapMapping.addTargetForeignKeyFieldName("ENT_MAP_VALUE.HOLDER_ID", "AGG_ENT_U1M_MAP_HOLDER.ID");
AggregateObjectMapping keyMapping = new AggregateObjectMapping();
keyMapping.setReferenceClass(AggregateMapKey.class);
keyMapping.addFieldNameTranslation("ENT_MAP_VALUE.MAP_KEY_1", "key->DIRECT");
keyMapping.setDescriptor(descriptor);
MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
policy.setKeyMapping(keyMapping);
policy.setValueMapping(mapMapping);
mapMapping.setContainerPolicy(policy);
descriptor.addMapping(mapMapping);
addDescriptor(descriptor);
}
use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class MapCollectionsProject method buildAggregateEntityMapHolderDescriptor.
protected void buildAggregateEntityMapHolderDescriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
// SECTION: DESCRIPTOR
descriptor.setJavaClass(AggregateEntityMapHolder.class);
Vector vector = new Vector();
vector.addElement("AGG_ENT_MAP_HOLDER");
descriptor.setTableNames(vector);
descriptor.addPrimaryKeyFieldName("AGG_ENT_MAP_HOLDER.ID");
// SECTION: PROPERTIES
descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
descriptor.setExistenceChecking("Check cache");
descriptor.setIdentityMapSize(100);
descriptor.setSequenceNumberName("AGG_ENT_MAP_HOLDER_ID");
descriptor.setSequenceNumberFieldName("ID");
// SECTION: DIRECTTOFIELDMAPPING
org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
directtofieldmapping.setAttributeName("id");
directtofieldmapping.setIsReadOnly(false);
directtofieldmapping.setGetMethodName("getId");
directtofieldmapping.setSetMethodName("setId");
directtofieldmapping.setFieldName("AGG_ENT_MAP_HOLDER.ID");
descriptor.addMapping(directtofieldmapping);
ManyToManyMapping mapMapping = new ManyToManyMapping();
mapMapping.setAttributeName("aggregateToEntityMap");
mapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
mapMapping.setReferenceClass(EntityMapValue.class);
mapMapping.setRelationTableName("AGG_ENT_MAP_REL");
mapMapping.setGetMethodName("getAggregateToEntityMap");
mapMapping.setSetMethodName("setAggregateToEntityMap");
mapMapping.addSourceRelationKeyFieldName("AGG_ENT_MAP_REL.HOLDER_ID", "AGG_ENT_MAP_HOLDER.ID");
mapMapping.addTargetRelationKeyFieldName("AGG_ENT_MAP_REL.VALUE_ID", "ENT_MAP_VALUE.ID");
AggregateObjectMapping keyMapping = new AggregateObjectMapping();
keyMapping.setReferenceClass(AggregateMapKey.class);
keyMapping.addFieldNameTranslation("AGG_ENT_MAP_REL.MAP_KEY", "key->DIRECT");
keyMapping.setDescriptor(descriptor);
MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
policy.setKeyMapping(keyMapping);
policy.setValueMapping(mapMapping);
mapMapping.setContainerPolicy(policy);
descriptor.addMapping(mapMapping);
addDescriptor(descriptor);
}
use of org.eclipse.persistence.mappings.AggregateObjectMapping in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildAggregateObjectMappingDescriptor.
protected ClassDescriptor buildAggregateObjectMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(AggregateObjectMapping.class);
descriptor.getInheritancePolicy().setParentClass(AggregateMapping.class);
XMLDirectMapping isNullAllowedMapping = new XMLDirectMapping();
isNullAllowedMapping.setAttributeName("isNullAllowed");
isNullAllowedMapping.setGetMethodName("isNullAllowed");
isNullAllowedMapping.setSetMethodName("setIsNullAllowed");
isNullAllowedMapping.setXPath(getPrimaryNamespaceXPath() + "allow-null/text()");
isNullAllowedMapping.setNullValue(Boolean.TRUE);
descriptor.addMapping(isNullAllowedMapping);
XMLCompositeCollectionMapping aggregateToSourceFieldNameAssociationsMapping = new XMLCompositeCollectionMapping();
aggregateToSourceFieldNameAssociationsMapping.setReferenceClass(FieldTranslation.class);
// Handle translation of fields associations string to field.
aggregateToSourceFieldNameAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
/*bug 322233: AttributeOverrides and AssociationOverride
* changed getAggregateToSourceFieldAssociations to hold String->DatabaseField associations
*/
AggregateObjectMapping mapping = (AggregateObjectMapping) object;
List<Association> associations = mapping.getAggregateToSourceFieldAssociations();
Vector<FieldTranslation> translations = new Vector<>(associations.size());
for (int index = 0; index < associations.size(); index++) {
Association association = associations.get(index);
FieldTranslation translation = new FieldTranslation();
translation.setKey(new DatabaseField((String) association.getKey()));
translation.setValue(association.getValue());
translations.add(translation);
}
return translations;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
AggregateObjectMapping mapping = (AggregateObjectMapping) object;
@SuppressWarnings({ "unchecked" }) Vector<Association> associations = (Vector<Association>) value;
for (int index = 0; index < associations.size(); index++) {
Association association = associations.get(index);
association.setKey(((DatabaseField) association.getKey()).getQualifiedName());
}
mapping.setAggregateToSourceFieldAssociations(associations);
}
});
aggregateToSourceFieldNameAssociationsMapping.setAttributeName("aggregateToSourceFieldNameAssociationsMapping");
aggregateToSourceFieldNameAssociationsMapping.setXPath(getPrimaryNamespaceXPath() + "field-translations/" + getPrimaryNamespaceXPath() + "field-translation");
descriptor.addMapping(aggregateToSourceFieldNameAssociationsMapping);
return descriptor;
}
Aggregations