mirror of
https://github.com/apache/openjpa.git
synced 2025-02-20 17:05:15 +00:00
OPENJPA-1432: preserve Compatibility flags set in compliance with the Specification.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@892397 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9e8b0ded0b
commit
5d9f08e728
@ -1477,9 +1477,21 @@ public class OpenJPAConfigurationImpl
|
||||
compatibilityPlugin.setString(compatibility);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a Compatibility instance is associated with the Specification,
|
||||
* we will configure this Compatibility instance instead of instantiating a
|
||||
* new one so that the compatibility flags set in compliance with the
|
||||
* Specification can be preserved.
|
||||
*/
|
||||
public Compatibility getCompatibilityInstance() {
|
||||
if (compatibilityPlugin.get() == null)
|
||||
compatibilityPlugin.instantiate(Compatibility.class, this);
|
||||
if (compatibilityPlugin.get() == null) {
|
||||
Specification spec = getSpecificationInstance();
|
||||
Compatibility comp = spec != null ? spec.getCompatibility() : null;
|
||||
if (comp == null)
|
||||
compatibilityPlugin.instantiate(Compatibility.class, this);
|
||||
else
|
||||
compatibilityPlugin.configure(comp, this);
|
||||
}
|
||||
return (Compatibility) compatibilityPlugin.get();
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ public class Specification {
|
||||
private int _major = 1;
|
||||
private String _minor = "0";
|
||||
private String _description = "";
|
||||
private Compatibility _compatibility;
|
||||
|
||||
private static Localizer _loc = Localizer.forPackage(Specification.class);
|
||||
|
||||
@ -144,4 +145,21 @@ public class Specification {
|
||||
return new Object[] {name,
|
||||
version.substring(0,dot), version.substring(dot+1)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate a compatibility object with this Specification instance
|
||||
* @param compatibility a Compatibility object with flags set in compliance
|
||||
* with this Specification instance.
|
||||
*/
|
||||
public void setCompatibility(Compatibility compatibility) {
|
||||
_compatibility = compatibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the compatibility object associated with this Specification instance.
|
||||
* @return
|
||||
*/
|
||||
public Compatibility getCompatibility() {
|
||||
return _compatibility;
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,20 @@ public class ObjectValue extends Value {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the given object.
|
||||
*/
|
||||
public Object configure(Object obj, Configuration conf) {
|
||||
return configure(obj, conf, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the given object.
|
||||
*/
|
||||
public Object configure(Object obj, Configuration conf, boolean fatal) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow subclasses to instantiate additional plugins. This method does
|
||||
* not perform configuration.
|
||||
|
@ -108,6 +108,18 @@ public class PluginValue extends ObjectValue {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the given object.
|
||||
*/
|
||||
public Object configure(Object obj, Configuration conf, boolean fatal) {
|
||||
Configurations.configureInstance(obj, conf, _props,
|
||||
(fatal) ? getProperty() : null);
|
||||
if (_singleton)
|
||||
set(obj, true);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
public void set(Object obj, boolean derived) {
|
||||
if (!_singleton)
|
||||
throw new IllegalStateException(_loc.get("not-singleton",
|
||||
|
@ -861,6 +861,7 @@ extends AbstractCachedEMFTestCase {
|
||||
});
|
||||
map.put("openjpa.jdbc.SynchronizeMappings",
|
||||
"buildSchema(ForeignKeys=true,SchemaAction='drop,add')");
|
||||
map.put("openjpa.Compatibility", "StrictIdentityValues=true");
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (Class<?> c : types) {
|
||||
|
@ -218,10 +218,12 @@ public class PersistenceProductDerivation
|
||||
conf.lockManagerPlugin.setString("mixed");
|
||||
conf.nontransactionalWrite.setDefault("true");
|
||||
conf.nontransactionalWrite.set(true);
|
||||
int specVersion = ((OpenJPAConfiguration) c).getSpecificationInstance().getVersion();
|
||||
Specification spec = ((OpenJPAConfiguration) c).getSpecificationInstance();
|
||||
int specVersion = spec.getVersion();
|
||||
Compatibility compatibility = conf.getCompatibilityInstance();
|
||||
spec.setCompatibility(compatibility);
|
||||
if (specVersion < 2) {
|
||||
compatibility.setFlushBeforeDetach(true);
|
||||
compatibility.setFlushBeforeDetach(true);
|
||||
compatibility.setCopyOnDetach(true);
|
||||
compatibility.setPrivatePersistentProperties(true);
|
||||
// Disable bean validation for spec level < 2 configurations
|
||||
|
Loading…
x
Reference in New Issue
Block a user