Search in sources :

Example 71 with RelationalDescriptor

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

the class TimestampVersion method descriptor.

public static RelationalDescriptor descriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(TimestampVersion.class);
    Vector vector = new Vector();
    vector.addElement("TSAO_LCK");
    descriptor.setTableNames(vector);
    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    descriptor.descriptorIsAggregate();
    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("t_id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setFieldName("TSAO_LCK.AGG_VERSION");
    descriptor.addMapping(directtofieldmapping);
    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping2 = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping2.setAttributeName("versionInfo");
    directtofieldmapping2.setIsReadOnly(false);
    directtofieldmapping2.setFieldName("TSAO_LCK.AGG_INFO");
    descriptor.addMapping(directtofieldmapping2);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 72 with RelationalDescriptor

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

the class DistributedProject method buildCompanyDescriptor.

public RelationalDescriptor buildCompanyDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.tests.distributedservers.Company.class);
    descriptor.addTableName("DIST_COMPANY");
    descriptor.addPrimaryKeyFieldName("DIST_COMPANY.ID");
    // Descriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("DIST_COMPANY.ID");
    descriptor.setSequenceNumberName("COMAPNY_SEQ");
    descriptor.setAlias("Company");
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("DIST_COMPANY.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping nameMapping = new DirectToFieldMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setFieldName("DIST_COMPANY.NAME");
    descriptor.addMapping(nameMapping);
    OneToManyMapping ownedItemsMapping = new OneToManyMapping();
    ownedItemsMapping.setAttributeName("ownedItems");
    ownedItemsMapping.setReferenceClass(org.eclipse.persistence.testing.tests.distributedservers.Item.class);
    ownedItemsMapping.dontUseIndirection();
    ownedItemsMapping.useCollectionClass(java.util.Vector.class);
    ownedItemsMapping.addTargetForeignKeyFieldName("DIST_ITEM.COMPANYOWNER", "DIST_COMPANY.ID");
    descriptor.addMapping(ownedItemsMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToManyMapping(org.eclipse.persistence.mappings.OneToManyMapping)

Example 73 with RelationalDescriptor

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

the class DistributedProject method buildDist_EmployeeDescriptor.

public RelationalDescriptor buildDist_EmployeeDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.tests.distributedservers.Dist_Employee.class);
    descriptor.addTableName("DIST_EMPLOYEE");
    descriptor.addPrimaryKeyFieldName("DIST_EMPLOYEE.ID");
    // Descriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("DIST_EMPLOYEE.ID");
    descriptor.setSequenceNumberName("EMPLOYEE_SEQ");
    descriptor.setAlias("Dist_Employee");
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("DIST_EMPLOYEE.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping nameMapping = new DirectToFieldMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setFieldName("DIST_EMPLOYEE.NAME");
    descriptor.addMapping(nameMapping);
    OneToManyMapping heldItemsMapping = new OneToManyMapping();
    heldItemsMapping.setAttributeName("heldItems");
    heldItemsMapping.setReferenceClass(org.eclipse.persistence.testing.tests.distributedservers.Item.class);
    heldItemsMapping.dontUseIndirection();
    heldItemsMapping.useCollectionClass(java.util.Vector.class);
    heldItemsMapping.addTargetForeignKeyFieldName("DIST_ITEM.EMPLOYEEHOLDER", "DIST_EMPLOYEE.ID");
    descriptor.addMapping(heldItemsMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToManyMapping(org.eclipse.persistence.mappings.OneToManyMapping)

Example 74 with RelationalDescriptor

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

the class IsolatedEmployeeProject method buildIsolatedParentDescriptor.

public RelationalDescriptor buildIsolatedParentDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(IsolatedParent.class);
    descriptor.addTableName("ISOLATED_PARENT");
    descriptor.addPrimaryKeyFieldName("ISOLATED_PARENT.ID");
    // ClassDescriptor Properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteFullIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("ISOLATED_PARENT.ID");
    descriptor.setSequenceNumberName("PARENT_SEQ");
    // IMPORTANT!
    descriptor.alwaysConformResultsInUnitOfWork();
    descriptor.setCacheIsolation(CacheIsolationType.ISOLATED);
    descriptor.setAlias("IsolatedParent");
    descriptor.setCacheSynchronizationType(ClassDescriptor.DO_NOT_SEND_CHANGES);
    descriptor.setAmendmentClass(IsolatedParent.class);
    descriptor.setAmendmentMethodName("afterLoad");
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Named Queries.
    // Named Query -- findParentBySerial
    ReadObjectQuery namedQuery0 = new ReadObjectQuery(IsolatedParent.class);
    namedQuery0.setName("findParentBySerial");
    namedQuery0.setShouldBindAllParameters(true);
    ExpressionBuilder expBuilder0 = namedQuery0.getExpressionBuilder();
    namedQuery0.setSelectionCriteria(expBuilder0.get("serial").equal(expBuilder0.getParameter("serial_p")));
    namedQuery0.addArgument("serial_p", java.lang.String.class);
    descriptor.getQueryManager().addQuery("findParentBySerial", namedQuery0);
    // Event Manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("ISOLATED_PARENT.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping serialMapping = new DirectToFieldMapping();
    serialMapping.setAttributeName("serial");
    serialMapping.setFieldName("ISOLATED_PARENT.SERIAL");
    descriptor.addMapping(serialMapping);
    OneToManyMapping childrenMapping = new OneToManyMapping();
    childrenMapping.setAttributeName("children");
    childrenMapping.setReferenceClass(IsolatedChild.class);
    childrenMapping.useTransparentCollection();
    childrenMapping.useCollectionClass(org.eclipse.persistence.indirection.IndirectList.class);
    childrenMapping.addTargetForeignKeyFieldName("ISOLATED_CHILD.PARENT_ID", "ISOLATED_PARENT.ID");
    childrenMapping.privateOwnedRelationship();
    descriptor.addMapping(childrenMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) OneToManyMapping(org.eclipse.persistence.mappings.OneToManyMapping) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 75 with RelationalDescriptor

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

the class IsolatedEmployeeProject method buildIsolatedChildDescriptor.

public RelationalDescriptor buildIsolatedChildDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(IsolatedChild.class);
    descriptor.addTableName("ISOLATED_CHILD");
    descriptor.addPrimaryKeyFieldName("ISOLATED_CHILD.ID");
    // ClassDescriptor Properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteFullIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("ISOLATED_CHILD.ID");
    descriptor.setSequenceNumberName("CHILD_SEQ");
    // IMPORTANT!
    descriptor.alwaysConformResultsInUnitOfWork();
    descriptor.setCacheIsolation(CacheIsolationType.ISOLATED);
    descriptor.setAlias("IsolatedChild");
    descriptor.setCacheSynchronizationType(ClassDescriptor.DO_NOT_SEND_CHANGES);
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Event Manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("ISOLATED_CHILD.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping serialMapping = new DirectToFieldMapping();
    serialMapping.setAttributeName("serial");
    serialMapping.setFieldName("ISOLATED_CHILD.SERIAL");
    descriptor.addMapping(serialMapping);
    DirectToFieldMapping deletedMapping = new DirectToFieldMapping();
    deletedMapping.setAttributeName("deleted");
    deletedMapping.setFieldName("ISOLATED_CHILD.DELETED");
    descriptor.addMapping(deletedMapping);
    OneToOneMapping parentMapping = new OneToOneMapping();
    parentMapping.setAttributeName("parent");
    parentMapping.setReferenceClass(IsolatedParent.class);
    parentMapping.useBasicIndirection();
    parentMapping.addForeignKeyFieldName("ISOLATED_CHILD.PARENT_ID", "ISOLATED_PARENT.ID");
    descriptor.addMapping(parentMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

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