use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class GetMethodReturnTypeNotValidTest method setup.
@Override
protected void setup() {
expectedException = DescriptorException.getMethodReturnTypeNotValid(new OneToManyMapping());
orgIntegrityChecker = getSession().getIntegrityChecker();
getSession().setIntegrityChecker(new IntegrityChecker());
getSession().getIntegrityChecker().dontCatchExceptions();
}
use of org.eclipse.persistence.mappings.OneToManyMapping 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;
}
use of org.eclipse.persistence.mappings.OneToManyMapping 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;
}
use of org.eclipse.persistence.mappings.OneToManyMapping 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;
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class IsolatedParent method afterLoad.
public static void afterLoad(ClassDescriptor descriptor) {
OneToManyMapping childrenMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("children");
Expression selectionCriteria = childrenMapping.buildSelectionCriteria();
ExpressionBuilder builder = new ExpressionBuilder();
childrenMapping.setSelectionCriteria(selectionCriteria.and(builder.get("deleted").equal("N")));
}
Aggregations