Search in sources :

Example 26 with RelationalDescriptor

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

the class AboutToInsertProject method buildAboutToInsertSingleTableObjectRelationalDataTypeDescriptor.

public RelationalDescriptor buildAboutToInsertSingleTableObjectRelationalDataTypeDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.events.AboutToInsertSingleTableObject.class);
    descriptor.addTableName("AboutToInsertSingle");
    descriptor.addPrimaryKeyFieldName("AboutToInsertSingle.ID");
    // RelationalDescriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.setAlias("AboutToInsertSingleTableObject");
    descriptor.setSequenceNumberFieldName("ID");
    descriptor.setSequenceNumberName("SINGLE_SEQ");
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setGetMethodName("getId");
    idMapping.setSetMethodName("setId");
    idMapping.setFieldName("AboutToInsertSingle.ID");
    descriptor.addMapping(idMapping);
    descriptor.getEventManager().addListener(new AboutToInsertEventAdapter("AboutToInsertSingle", "EXTRA_NUMBER"));
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 27 with RelationalDescriptor

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

the class Address method descriptor.

public static RelationalDescriptor descriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    /* First define the class, table and descriptor properties. */
    descriptor.setJavaClass(Address.class);
    descriptor.setTableName("EADDRESS");
    descriptor.setPrimaryKeyFieldName("ID");
    descriptor.setSequenceNumberName("SEQ");
    descriptor.setSequenceNumberFieldName("ID");
    /* Next define the attribute mappings. */
    descriptor.addDirectMapping("id", "ID");
    descriptor.addDirectMapping("address", "DESCR");
    descriptor.getQueryManager().setUpdateQuery(new org.eclipse.persistence.queries.UpdateObjectQuery("UPDATE EADDRESS SET DESCR = #DESCR WHERE ID = #ID"));
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 28 with RelationalDescriptor

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

the class FUVLProject method buildAddressVLIODescriptor.

public RelationalDescriptor buildAddressVLIODescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.forceupdate.AddressVLIO.class);
    descriptor.addTableName("ADDRESSVLIO");
    descriptor.addPrimaryKeyFieldName("ADDRESSVLIO.ADDRESS_ID");
    // RelationalDescriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("ADDRESSVLIO.ADDRESS_ID");
    descriptor.setSequenceNumberName("ADDRVLIO_SEQ");
    descriptor.useVersionLocking("VERSION", false);
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("ADDRESSVLIO.ADDRESS_ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping streetMapping = new DirectToFieldMapping();
    streetMapping.setAttributeName("street");
    streetMapping.setFieldName("ADDRESSVLIO.STREET");
    descriptor.addMapping(streetMapping);
    DirectToFieldMapping cityMapping = new DirectToFieldMapping();
    cityMapping.setAttributeName("city");
    cityMapping.setFieldName("ADDRESSVLIO.CITY");
    descriptor.addMapping(cityMapping);
    DirectToFieldMapping provinceMapping = new DirectToFieldMapping();
    provinceMapping.setAttributeName("province");
    provinceMapping.setFieldName("ADDRESSVLIO.PROVINCE");
    descriptor.addMapping(provinceMapping);
    DirectToFieldMapping postalCodeMapping = new DirectToFieldMapping();
    postalCodeMapping.setAttributeName("postalCode");
    postalCodeMapping.setFieldName("ADDRESSVLIO.P_CODE");
    descriptor.addMapping(postalCodeMapping);
    DirectToFieldMapping countryMapping = new DirectToFieldMapping();
    countryMapping.setAttributeName("country");
    countryMapping.setFieldName("ADDRESSVLIO.COUNTRY");
    descriptor.addMapping(countryMapping);
    DirectToFieldMapping versionMapping = new DirectToFieldMapping();
    versionMapping.setAttributeName("version");
    versionMapping.setFieldName("ADDRESSVLIO.VERSION");
    descriptor.addMapping(versionMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 29 with RelationalDescriptor

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

the class FUVLProject method buildPhoneNumberVLICDescriptor.

public RelationalDescriptor buildPhoneNumberVLICDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.forceupdate.PhoneNumberVLIC.class);
    descriptor.addTableName("PHONEVLIC");
    descriptor.addPrimaryKeyFieldName("PHONEVLIC.EMP_ID");
    descriptor.addPrimaryKeyFieldName("PHONEVLIC.TYPE");
    // RelationalDescriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries
    // Event manager.
    // Mappings.
    DirectToFieldMapping typeMapping = new DirectToFieldMapping();
    typeMapping.setAttributeName("type");
    typeMapping.setFieldName("PHONEVLIC.TYPE");
    descriptor.addMapping(typeMapping);
    DirectToFieldMapping areaCodeMapping = new DirectToFieldMapping();
    areaCodeMapping.setAttributeName("areaCode");
    areaCodeMapping.setFieldName("PHONEVLIC.AREA_CODE");
    descriptor.addMapping(areaCodeMapping);
    DirectToFieldMapping numberMapping = new DirectToFieldMapping();
    numberMapping.setAttributeName("number");
    numberMapping.setFieldName("PHONEVLIC.P_NUMBER");
    descriptor.addMapping(numberMapping);
    OneToOneMapping ownerMapping = new OneToOneMapping();
    ownerMapping.setAttributeName("owner");
    ownerMapping.setReferenceClass(org.eclipse.persistence.testing.models.forceupdate.EmployeeVLIC.class);
    ownerMapping.useBasicIndirection();
    ownerMapping.addForeignKeyFieldName("PHONEVLIC.EMP_ID", "EMPLOYEEVLIC.EMP_ID");
    descriptor.addMapping(ownerMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 30 with RelationalDescriptor

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

the class Promoter method descriptor.

// Movie descriptor
public static RelationalDescriptor descriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.readonly.Promoter.class);
    descriptor.setTableName("RO_PROMO");
    descriptor.addPrimaryKeyFieldName("PROMO_ID");
    descriptor.setSequenceNumberName("PROMO_SEQ");
    descriptor.setSequenceNumberFieldName("PROMO_ID");
    descriptor.addDirectMapping("id", "PROMO_ID");
    descriptor.addDirectMapping("name", "NAME");
    /*
// The promoter operates in a collection of countries.
org.eclipse.persistence.mappings.OneToManyMapping phoneNumbersMapping = new org.eclipse.persistence.mappings.OneToManyMapping() ;
phoneNumbersMapping.setAttributeName("phoneNumbers");
phoneNumbersMapping.setReferenceClass(PhoneNumber.class);
phoneNumbersMapping.setTargetForeignKeyFieldName("PROMO_ID");
phoneNumbersMapping.privateOwnedRelationship();
//    phoneNumbersMapping.dontUseIndirection();
descriptor.addMapping(phoneNumbersMapping);
*/
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

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