mirror of https://github.com/apache/openjpa.git
Only treat methods as persistent by default if there is a setter for the method in the described class.
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@450649 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7baaaf4b76
commit
e1e96406e8
|
@ -245,6 +245,21 @@ class PersistenceMetaDataDefaults
|
||||||
int mods = member.getModifiers();
|
int mods = member.getModifiers();
|
||||||
if (Modifier.isTransient(mods))
|
if (Modifier.isTransient(mods))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (member instanceof Method) {
|
||||||
|
try {
|
||||||
|
// check for setters for methods
|
||||||
|
Method setter = meta.getDescribedType().getDeclaredMethod("set"
|
||||||
|
+ name.substring(0, 1).toUpperCase() + name.substring(1),
|
||||||
|
new Class[] { ((Method) member).getReturnType() });
|
||||||
|
if (setter == null)
|
||||||
|
return false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// e.g., NoSuchMethodException
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PersistenceStrategy strat = getPersistenceStrategy(null, member);
|
PersistenceStrategy strat = getPersistenceStrategy(null, member);
|
||||||
if (strat == null || strat == PersistenceStrategy.TRANSIENT)
|
if (strat == null || strat == PersistenceStrategy.TRANSIENT)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue