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); }
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); }
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); }