use of org.eclipse.persistence.descriptors.SerializedObjectPolicy in project eclipselink by eclipse-ee4j.
the class AbstractSerializedObjectPolicy method initializeField.
@Override
public void initializeField(AbstractSession session) {
if (this.field == null) {
session.getIntegrityChecker().handleError(DescriptorException.serializedObjectPolicyFieldNotSet(this.descriptor));
return;
}
if (this.descriptor.isChildDescriptor()) {
SerializedObjectPolicy parentPolicy = this.descriptor.getInheritancePolicy().getParentDescriptor().getSerializedObjectPolicy();
if (parentPolicy != null && parentPolicy.getField() == this.field) {
return;
}
}
this.field = this.descriptor.buildField(this.field);
this.descriptor.getFields().add(this.field);
}
use of org.eclipse.persistence.descriptors.SerializedObjectPolicy in project eclipselink by eclipse-ee4j.
the class Customizer method customize.
@Override
public void customize(Session session) throws Exception {
String sessionName = session.getName();
Integer numberOfCalls = (Integer) sessionCalls.get(sessionName);
int num = 0;
if (numberOfCalls != null) {
num = numberOfCalls;
}
sessionCalls.put(sessionName, num + 1);
// **temp
session.getEventManager().addListener(new AcquireReleaseListener());
session.getEventManager().addListener(new SessionEventAdapter() {
@Override
public void postLogin(SessionEvent event) {
if (event.getSession().getPlatform().isPostgreSQL()) {
event.getSession().setQueryTimeoutDefault(0);
}
}
});
if (Boolean.parseBoolean(System.getProperty("sop"))) {
boolean isRecoverable = Boolean.parseBoolean(System.getProperty("sop.recoverable"));
Class<?> sopClass = Class.forName("oracle.toplink.exalogic.sop.SerializedObjectPolicy");
Method setIsRecoverableMethod = null;
if (isRecoverable) {
setIsRecoverableMethod = sopClass.getDeclaredMethod("setIsRecoverable", boolean.class);
}
Class<?>[] sopEntities = { Employee.class, Address.class, Project.class };
for (Class<?> sopEntity : sopEntities) {
ClassDescriptor descriptor = session.getDescriptor(sopEntity);
Object sop = sopClass.getConstructor().newInstance();
if (isRecoverable) {
setIsRecoverableMethod.invoke(sop, true);
}
((SerializedObjectPolicy) sop).setField(new DatabaseField("SOP"));
descriptor.setSerializedObjectPolicy((SerializedObjectPolicy) sop);
if (descriptor.usesOptimisticLocking() && (descriptor.getOptimisticLockingPolicy() instanceof VersionLockingPolicy)) {
((VersionLockingPolicy) descriptor.getOptimisticLockingPolicy()).setIsCascaded(true);
}
}
}
}
Aggregations