use of org.eclipse.persistence.descriptors.PessimisticLockingPolicy in project eclipselink by eclipse-ee4j.
the class CMPDescriptorPessimisticLockingTest method setup.
@Override
protected void setup() {
// Modify the employee project to use custom SQL queries
EmployeeProject project = new EmployeeProject();
ClassDescriptor employeeDescriptor = project.getDescriptors().get(Employee.class);
ClassDescriptor addressDescriptor = project.getDescriptors().get(Address.class);
employeeDescriptor.setCMPPolicy(new CMPPolicy());
addressDescriptor.setCMPPolicy(new CMPPolicy());
employeeDescriptor.getCMPPolicy().setPessimisticLockingPolicy(new PessimisticLockingPolicy());
addressDescriptor.getCMPPolicy().setPessimisticLockingPolicy(new PessimisticLockingPolicy());
employeeDescriptor.getCMPPolicy().getPessimisticLockingPolicy().setLockingMode(ObjectLevelReadQuery.LOCK);
addressDescriptor.getCMPPolicy().getPessimisticLockingPolicy().setLockingMode(ObjectLevelReadQuery.LOCK_NOWAIT);
// write project to an XML project file
XMLProjectWriter.write(PROJECT_FILE, project);
}
use of org.eclipse.persistence.descriptors.PessimisticLockingPolicy in project eclipselink by eclipse-ee4j.
the class WriteNewPessimisticLockedObjectTest method setup.
@Override
protected void setup() {
PessimisticLockingPolicy policy = new PessimisticLockingPolicy();
policy.setLockingMode(ObjectLevelReadQuery.LOCK_NOWAIT);
CMPPolicy cmpPolicy = new CMPPolicy();
cmpPolicy.setPessimisticLockingPolicy(policy);
ClassDescriptor empDescriptor = getSession().getDescriptor(Employee.class);
oldCMPPolicy = empDescriptor.getCMPPolicy();
empDescriptor.setCMPPolicy(cmpPolicy);
empDescriptor.getQueryManager().getReadObjectQuery().setLockMode(ObjectLevelReadQuery.DEFAULT_LOCK_MODE);
this.oldLevel = empDescriptor.getUnitOfWorkCacheIsolationLevel();
empDescriptor.setUnitOfWorkCacheIsolationLevel(ClassDescriptor.ISOLATE_CACHE_ALWAYS);
// Flush the cache
getSession().getIdentityMapAccessor().initializeIdentityMaps();
getAbstractSession().beginTransaction();
}
use of org.eclipse.persistence.descriptors.PessimisticLockingPolicy in project eclipselink by eclipse-ee4j.
the class ProjectClassGeneratorWithCMPDescriptorTest method setup.
@Override
protected void setup() {
project = new org.eclipse.persistence.testing.models.employee.relational.EmployeeProject();
// initialize new CMP descriptor with non-default settings
CMPPolicy cmpPolicy = new CMPPolicy();
cmpPolicy.setPessimisticLockingPolicy(new PessimisticLockingPolicy());
cmpPolicy.setDeferModificationsUntilCommit(5);
cmpPolicy.setForceUpdate(true);
cmpPolicy.setNonDeferredCreateTime(1000);
cmpPolicy.setUpdateAllFields(true);
cmpPolicy.setPessimisticLockingPolicy(new PessimisticLockingPolicy());
cmpPolicy.getPessimisticLockingPolicy().setLockingMode(ObjectLevelReadQuery.LOCK_NOWAIT);
// set CMP descriptor to Address descriptor
project.getDescriptor(org.eclipse.persistence.testing.models.employee.domain.Address.class).setCMPPolicy(cmpPolicy);
}
Aggregations