Search in sources :

Example 81 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class MapCollectionsProject method buildAggregateDirectMapHolderDescriptor.

protected void buildAggregateDirectMapHolderDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(AggregateDirectMapHolder.class);
    Vector vector = new Vector();
    vector.addElement("AGG_DIR_MAP_HOLDER");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("AGG_DIR_MAP_HOLDER.ID");
    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberName("AGG_DIR_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_DIR_MAP_HOLDER.ID");
    descriptor.addMapping(directtofieldmapping);
    DirectMapMapping directMapMapping = new DirectMapMapping();
    directMapMapping.setAttributeName("aggregateToDirectMap");
    directMapMapping.setGetMethodName("getAggregateToDirectMap");
    directMapMapping.setSetMethodName("setAggregateToDirectMap");
    directMapMapping.setReferenceTableName("AGG_DIR_MAP_REL");
    directMapMapping.setDirectFieldName("AGG_DIR_MAP_REL.MAP_VALUE");
    directMapMapping.addReferenceKeyFieldName("AGG_DIR_MAP_REL.HOLDER_ID", "AGG_DIR_MAP_HOLDER.ID");
    directMapMapping.setDirectFieldClassification(Integer.class);
    directMapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
    AggregateObjectMapping keyMapping = new AggregateObjectMapping();
    keyMapping.setReferenceClass(AggregateMapKey.class);
    keyMapping.addFieldNameTranslation("AGG_DIR_MAP_REL.MAP_KEY", "key->DIRECT");
    keyMapping.setDescriptor(descriptor);
    MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
    policy.setKeyMapping(keyMapping);
    policy.setValueMapping(directMapMapping);
    directMapMapping.setContainerPolicy(policy);
    descriptor.addMapping(directMapMapping);
    addDescriptor(descriptor);
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) AggregateObjectMapping(org.eclipse.persistence.mappings.AggregateObjectMapping) DirectMapMapping(org.eclipse.persistence.mappings.DirectMapMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) TransparentIndirectionPolicy(org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy) DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) MappedKeyMapContainerPolicy(org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy)

Example 82 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class MapCollectionsProject method buildEntityAggregateMapHolderDescriptor.

protected void buildEntityAggregateMapHolderDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(EntityAggregateMapHolder.class);
    Vector vector = new Vector();
    vector.addElement("ENT_AGG_MAP_HOLDER");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("ENT_AGG_MAP_HOLDER.ID");
    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberName("ENT_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("ENT_AGG_MAP_HOLDER.ID");
    descriptor.addMapping(directtofieldmapping);
    // SECTION: AGGREGATECOLLECTIONMAPPING
    org.eclipse.persistence.mappings.AggregateCollectionMapping aggregatecollectionmapping = new org.eclipse.persistence.mappings.AggregateCollectionMapping();
    aggregatecollectionmapping.setAttributeName("entityToAggregateMap");
    aggregatecollectionmapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
    aggregatecollectionmapping.setGetMethodName("getEntityToAggregateMap");
    aggregatecollectionmapping.setSetMethodName("setEntityToAggregateMap");
    aggregatecollectionmapping.setReferenceClass(AggregateMapValue.class);
    aggregatecollectionmapping.addTargetForeignKeyFieldName("ENT_AGG_MAP_REL.HOLDER_ID", "ENT_AGG_MAP_HOLDER.ID");
    aggregatecollectionmapping.addFieldNameTranslation("ENT_AGG_MAP_REL.MAP_VALUE", "value->DIRECT");
    org.eclipse.persistence.mappings.OneToOneMapping keyMapping = new org.eclipse.persistence.mappings.OneToOneMapping();
    keyMapping.setReferenceClass(EntityMapKey.class);
    keyMapping.addForeignKeyFieldName("ENT_AGG_MAP_REL.KEY_ID", "ENT_MAP_KEY.ID");
    keyMapping.dontUseIndirection();
    keyMapping.setDescriptor(descriptor);
    MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
    policy.setKeyMapping(keyMapping);
    policy.setValueMapping(aggregatecollectionmapping);
    aggregatecollectionmapping.setContainerPolicy(policy);
    descriptor.addMapping(aggregatecollectionmapping);
    addDescriptor(descriptor);
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping) TransparentIndirectionPolicy(org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy) DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) MappedKeyMapContainerPolicy(org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Example 83 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class MapCollectionsProject method buildEntityEntityU1MMapHolderDescriptor.

protected void buildEntityEntityU1MMapHolderDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(EntityEntityU1MMapHolder.class);
    Vector vector = new Vector();
    vector.addElement("ENT_ENT_U1M_MAP_HOLDER");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("ENT_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("ENT_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("ENT_ENT_U1M_MAP_HOLDER.ID");
    descriptor.addMapping(directtofieldmapping);
    UnidirectionalOneToManyMapping mapMapping = new UnidirectionalOneToManyMapping();
    mapMapping.setAttributeName("entityToEntityMap");
    mapMapping.setReferenceClass(EntityMapValue.class);
    mapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
    mapMapping.setGetMethodName("getEntityToEntityMap");
    mapMapping.setSetMethodName("setEntityToEntityMap");
    mapMapping.addTargetForeignKeyFieldName("ENT_MAP_VALUE.HOLDER_ID", "ENT_ENT_U1M_MAP_HOLDER.ID");
    org.eclipse.persistence.mappings.OneToOneMapping keyMapping = new org.eclipse.persistence.mappings.OneToOneMapping();
    keyMapping.setReferenceClass(EntityMapKey.class);
    keyMapping.addForeignKeyFieldName("ENT_MAP_VALUE.KEY_ID", "ENT_MAP_KEY.ID");
    keyMapping.dontUseIndirection();
    keyMapping.setDescriptor(descriptor);
    MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
    policy.setKeyMapping(keyMapping);
    policy.setValueMapping(mapMapping);
    mapMapping.setContainerPolicy(policy);
    descriptor.addMapping(mapMapping);
    addDescriptor(descriptor);
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping) TransparentIndirectionPolicy(org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy) DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) MappedKeyMapContainerPolicy(org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy) UnidirectionalOneToManyMapping(org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Example 84 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class MapCollectionsProject method buildDirectEntityMapHolderDescriptor.

protected void buildDirectEntityMapHolderDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(DirectEntityMapHolder.class);
    Vector vector = new Vector();
    vector.addElement("DIR_ENT_MAP_HOLDER");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("DIR_ENT_MAP_HOLDER.ID");
    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberName("DIR_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("DIR_ENT_MAP_HOLDER.ID");
    descriptor.addMapping(directtofieldmapping);
    ManyToManyMapping mapMapping = new ManyToManyMapping();
    mapMapping.setAttributeName("directToEntityMap");
    mapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
    mapMapping.setReferenceClass(EntityMapValue.class);
    mapMapping.setRelationTableName("DIR_ENT_MAP_REL");
    mapMapping.setGetMethodName("getDirectToEntityMap");
    mapMapping.setSetMethodName("setDirectToEntityMap");
    mapMapping.addSourceRelationKeyFieldName("DIR_ENT_MAP_REL.HOLDER_ID", "DIR_ENT_MAP_HOLDER.ID");
    mapMapping.addTargetRelationKeyFieldName("DIR_ENT_MAP_REL.VALUE_ID", "ENT_MAP_VALUE.ID");
    org.eclipse.persistence.mappings.DirectToFieldMapping keyMapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    keyMapping.setFieldName("DIR_ENT_MAP_REL.MAP_KEY");
    keyMapping.setAttributeClassification(Integer.class);
    keyMapping.setDescriptor(descriptor);
    MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
    policy.setKeyMapping(keyMapping);
    policy.setValueMapping(mapMapping);
    mapMapping.setContainerPolicy(policy);
    descriptor.addMapping(mapMapping);
    addDescriptor(descriptor);
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) ManyToManyMapping(org.eclipse.persistence.mappings.ManyToManyMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) TransparentIndirectionPolicy(org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy) DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) MappedKeyMapContainerPolicy(org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy)

Example 85 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class MapCollectionsProject method buildDirectEntityU1MMapHolderDescriptor.

protected void buildDirectEntityU1MMapHolderDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(DirectEntityU1MMapHolder.class);
    Vector vector = new Vector();
    vector.addElement("DIR_ENT_U1M_MAP_HOLDER");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("DIR_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("DIR_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("DIR_ENT_U1M_MAP_HOLDER.ID");
    descriptor.addMapping(directtofieldmapping);
    UnidirectionalOneToManyMapping mapMapping = new UnidirectionalOneToManyMapping();
    mapMapping.setAttributeName("directToEntityMap");
    mapMapping.setReferenceClass(EntityMapValue.class);
    mapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
    mapMapping.setGetMethodName("getDirectToEntityMap");
    mapMapping.setSetMethodName("setDirectToEntityMap");
    mapMapping.addTargetForeignKeyFieldName("ENT_MAP_VALUE.HOLDER_ID", "DIR_ENT_U1M_MAP_HOLDER.ID");
    org.eclipse.persistence.mappings.DirectToFieldMapping keyMapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    keyMapping.setFieldName("ENT_MAP_VALUE.MAP_KEY");
    keyMapping.setAttributeClassification(Integer.class);
    keyMapping.setDescriptor(descriptor);
    MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
    policy.setKeyMapping(keyMapping);
    policy.setValueMapping(mapMapping);
    mapMapping.setContainerPolicy(policy);
    descriptor.addMapping(mapMapping);
    addDescriptor(descriptor);
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) TransparentIndirectionPolicy(org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy) DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) MappedKeyMapContainerPolicy(org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy) UnidirectionalOneToManyMapping(org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping)

Aggregations

RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)306 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)122 OneToOneMapping (org.eclipse.persistence.mappings.OneToOneMapping)43 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)26 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)19 OneToManyMapping (org.eclipse.persistence.mappings.OneToManyMapping)18 Vector (java.util.Vector)17 TransparentIndirectionPolicy (org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy)15 MappedKeyMapContainerPolicy (org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy)15 TransformationMapping (org.eclipse.persistence.mappings.TransformationMapping)13 IntegrityChecker (org.eclipse.persistence.exceptions.IntegrityChecker)12 ManyToManyMapping (org.eclipse.persistence.mappings.ManyToManyMapping)10 java.util (java.util)9 AggregateObjectMapping (org.eclipse.persistence.mappings.AggregateObjectMapping)8 org.eclipse.persistence.mappings (org.eclipse.persistence.mappings)7 UnidirectionalOneToManyMapping (org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping)6 ObjectTypeConverter (org.eclipse.persistence.mappings.converters.ObjectTypeConverter)6 DatabaseRecord (org.eclipse.persistence.sessions.DatabaseRecord)6 DirectCollectionMapping (org.eclipse.persistence.mappings.DirectCollectionMapping)5 DirectMapMapping (org.eclipse.persistence.mappings.DirectMapMapping)4