OPENJPA-2325: Correct evaluation of identity type for MappedSuperclass without an identity field

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1436957 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2013-01-22 14:35:32 +00:00
parent 2c3ec95860
commit 01cae73832
1 changed files with 20 additions and 15 deletions

View File

@ -179,7 +179,7 @@ public class ClassMetaData
private List<Class<?>> _interfaces = null; private List<Class<?>> _interfaces = null;
private final Map<Class<?>,Map<String,String>> _ifaceMap = private final Map<Class<?>,Map<String,String>> _ifaceMap =
new HashMap<Class<?>,Map<String,String>>(); new HashMap<Class<?>,Map<String,String>>();
private int _identity = ID_UNKNOWN; private Integer _identity = null;
private int _idStrategy = ValueStrategies.NONE; private int _idStrategy = ValueStrategies.NONE;
private int _accessType = AccessCode.UNKNOWN; private int _accessType = AccessCode.UNKNOWN;
@ -440,21 +440,25 @@ public class ClassMetaData
* primary key fields, and {@link #ID_APPLICATION} otherwise. * primary key fields, and {@link #ID_APPLICATION} otherwise.
*/ */
public int getIdentityType() { public int getIdentityType() {
if (_identity == ID_UNKNOWN) { if (_identity != null) {
ClassMetaData sup = getPCSuperclassMetaData(); return _identity;
if (sup != null && sup.getIdentityType() != ID_UNKNOWN) } else {
_identity = sup.getIdentityType(); ClassMetaData sup = getPCSuperclassMetaData();
else if (getPrimaryKeyFields().length > 0) if (sup != null && sup.getIdentityType() != ID_UNKNOWN)
_identity = ID_APPLICATION; _identity = sup.getIdentityType();
else if (isMapped()) else if (getPrimaryKeyFields().length > 0)
_identity = ID_DATASTORE; _identity = ID_APPLICATION;
else else if (isMapped())
_identity = _repos.getMetaDataFactory().getDefaults(). _identity = ID_DATASTORE;
getDefaultIdentityType(); else if (isAbstract())
} _identity = ID_UNKNOWN;
else
_identity = _repos.getMetaDataFactory().getDefaults().
getDefaultIdentityType();
}
return _identity; return _identity;
} }
/** /**
* The type of identity being used. This will be one of: * The type of identity being used. This will be one of:
* <ul> * <ul>
@ -2511,8 +2515,9 @@ public class ClassMetaData
_embeddable = meta._embeddable; _embeddable = meta._embeddable;
_interface = (meta.isManagedInterface()) ? Boolean.TRUE : Boolean.FALSE; _interface = (meta.isManagedInterface()) ? Boolean.TRUE : Boolean.FALSE;
setIntercepting(meta.isIntercepting()); setIntercepting(meta.isIntercepting());
_abstract = meta.isAbstract();
_impl = meta.getInterfaceImpl(); _impl = meta.getInterfaceImpl();
_identity = meta.getIdentityType(); _identity = meta._identity == null ? null : meta.getIdentityType();
_idStrategy = meta.getIdentityStrategy(); _idStrategy = meta.getIdentityStrategy();
_seqName = meta.getIdentitySequenceName(); _seqName = meta.getIdentitySequenceName();
_seqMeta = null; _seqMeta = null;