Search in sources :

Example 61 with RelationalDescriptor

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

the class IllegalArgumentWhileSettingValueThruInstanceVariableAccessorTest method descriptor.

public RelationalDescriptor descriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.tests.validation.PersonInstanceAccess.class);
    descriptor.addTableName("EMPLOYEE");
    descriptor.addPrimaryKeyFieldName("EMPLOYEE.EMP_ID");
    // Descriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("EMP_ID");
    descriptor.setSequenceNumberName("EMP_SEQ");
    descriptor.setAlias("EMPLOYEE");
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries
    // Event manager.
    // Mappings.
    DirectToFieldMapping p_idMapping = new DirectToFieldMapping();
    p_idMapping.setAttributeName("p_id");
    p_idMapping.setFieldName("EMPLOYEE.EMP_ID");
    descriptor.addMapping(p_idMapping);
    DirectToFieldMapping p_nameMapping = new DirectToFieldMapping();
    p_nameMapping.setAttributeName("p_name");
    p_nameMapping.setFieldName("EMPLOYEE.F_NAME");
    descriptor.addMapping(p_nameMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 62 with RelationalDescriptor

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

the class DescriptorForInterfaceIsMissingTest method buildProjectDescriptor.

public RelationalDescriptor buildProjectDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.employee.domain.Project.class);
    descriptor.addTableName("PROJECT");
    descriptor.addPrimaryKeyFieldName("PROJECT.PROJ_ID");
    // Inheritance properties.
    descriptor.getInheritancePolicy().setClassIndicatorFieldName("PROJ_TYPE");
    descriptor.getInheritancePolicy().addClassIndicator(org.eclipse.persistence.testing.models.employee.domain.LargeProject.class, "L");
    descriptor.getInheritancePolicy().addClassIndicator(org.eclipse.persistence.testing.models.employee.domain.SmallProject.class, "S");
    // Interface properties.
    // the following causes the correct error to occure.
    descriptor.getInterfacePolicy().addParentInterface(org.eclipse.persistence.testing.models.employee.interfaces.LargeProject.class);
    // Descriptor properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteFullIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("PROJ_ID");
    descriptor.setSequenceNumberName("PROJ_SEQ");
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Event manager.
    // Mappings.
    DirectToFieldMapping descriptionMapping = new DirectToFieldMapping();
    descriptionMapping.setAttributeName("description");
    descriptionMapping.setFieldName("PROJECT.DESCRIP");
    descriptionMapping.setNullValue("");
    descriptor.addMapping(descriptionMapping);
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("PROJECT.PROJ_ID");
    descriptor.addMapping(idMapping);
    /*    OneToOneMapping teamLeaderMapping = new OneToOneMapping();
    teamLeaderMapping.setAttributeName("teamLeader");
    teamLeaderMapping.setReferenceClass(org.eclipse.persistence.testing.models.employee.domain.Employee.class);
    teamLeaderMapping.useBasicIndirection();
    teamLeaderMapping.addForeignKeyFieldName("PROJECT.LEADER_ID", "EMPLOYEE.EMP_ID");
    descriptor.addMapping(teamLeaderMapping);
    */
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 63 with RelationalDescriptor

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

the class JGeometryProject method buildWrappedSpatialDescriptor.

public ClassDescriptor buildWrappedSpatialDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial.class);
    descriptor.addTableName("WRAPPED_SPATIAL");
    descriptor.addPrimaryKeyFieldName("WRAPPED_SPATIAL.GID");
    // Descriptor Properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setAlias("WrappedSpatial");
    descriptor.setAmendmentClass(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.TopLinkAfterLoad.class);
    descriptor.setAmendmentMethodName("afterLoadWrappedSpatial");
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries.
    // Named Query -- findAllWrappedSpatial
    ReadAllQuery namedQuery0 = new ReadAllQuery(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial.class);
    namedQuery0.setName("findAllWrappedSpatial");
    namedQuery0.setQueryTimeout(0);
    namedQuery0.setCacheUsage(ObjectLevelReadQuery.CheckCacheByPrimaryKey);
    namedQuery0.setLockMode(ObjectLevelReadQuery.NO_LOCK);
    descriptor.getQueryManager().addQuery("findAllWrappedSpatial", namedQuery0);
    // Event Manager.
    // Query keys.
    descriptor.addDirectQueryKey("geometry.id", "WRAPPED_SPATIAL.GEOMETRY.ID");
    descriptor.addDirectQueryKey("geometry.geom", "WRAPPED_SPATIAL.GEOMETRY.GEOM");
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("WRAPPED_SPATIAL.GID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping geometryMapping = new DirectToFieldMapping();
    geometryMapping.setAttributeName("geometry");
    ObjectRelationalDatabaseField f = new ObjectRelationalDatabaseField("WRAPPED_SPATIAL.GEOMETRY");
    geometryMapping.setField(f);
    geometryMapping.setFieldType(java.sql.Types.STRUCT);
    descriptor.addMapping(geometryMapping);
    descriptor.applyAmendmentMethod();
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery)

Example 64 with RelationalDescriptor

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

the class JGeometryProject method buildSimpleSpatialDescriptor.

public ClassDescriptor buildSimpleSpatialDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial.class);
    descriptor.addTableName("SIMPLE_SPATIAL");
    descriptor.addPrimaryKeyFieldName("SIMPLE_SPATIAL.GID");
    // Descriptor Properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setAlias("SimpleSpatial");
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries.
    // Named Query -- findAllSimpleSpatial
    ReadAllQuery namedQuery0 = new ReadAllQuery(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial.class);
    namedQuery0.setName("findAllSimpleSpatial");
    namedQuery0.setQueryTimeout(0);
    namedQuery0.setCacheUsage(ObjectLevelReadQuery.CheckCacheByPrimaryKey);
    namedQuery0.setLockMode(ObjectLevelReadQuery.NO_LOCK);
    descriptor.getQueryManager().addQuery("findAllSimpleSpatial", namedQuery0);
    // Event Manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("SIMPLE_SPATIAL.GID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping geometryMapping = new DirectToFieldMapping();
    geometryMapping.setAttributeName("geometry");
    ObjectRelationalDatabaseField f = new ObjectRelationalDatabaseField("SIMPLE_SPATIAL.GEOMETRY");
    geometryMapping.setField(f);
    geometryMapping.setFieldType(java.sql.Types.STRUCT);
    descriptor.addMapping(geometryMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery)

Example 65 with RelationalDescriptor

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

the class ProjectProject method buildLargeBusinessProjectDescriptor.

/**
 * TopLink generated method.
 * <b>WARNING</b>: This code was generated by an automated tool.
 * Any changes will be lost when the code is re-generated
 */
protected void buildLargeBusinessProjectDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.multipletable.LargeBusinessProject.class);
    descriptor.getInheritancePolicy().setParentClass(org.eclipse.persistence.testing.models.multipletable.BusinessProject.class);
    Vector vector = new Vector();
    vector.addElement("LPROJ");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("LPROJ.PROJ_ID");
    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    descriptor.getInheritancePolicy().setShouldReadSubclasses(false);
    // SECTION: COPY POLICY
    descriptor.createCopyPolicy("constructor");
    // SECTION: INSTANTIATION POLICY
    descriptor.createInstantiationPolicy("constructor");
    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("milestoneVersion");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setFieldName("LPROJ.MILESTONE");
    descriptor.addMapping(directtofieldmapping);
    // SECTION: ONETOONEMAPPING
    org.eclipse.persistence.mappings.OneToOneMapping onetoonemapping = new org.eclipse.persistence.mappings.OneToOneMapping();
    onetoonemapping.setAttributeName("budget");
    onetoonemapping.setIsReadOnly(false);
    onetoonemapping.setUsesIndirection(false);
    onetoonemapping.setReferenceClass(org.eclipse.persistence.testing.models.multipletable.Budget.class);
    onetoonemapping.setIsPrivateOwned(true);
    onetoonemapping.addForeignKeyFieldName("LPROJ.BUDGET_ID", "BUDGET.ID");
    descriptor.addMapping(onetoonemapping);
    addDescriptor(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