From 01cae73832fd7b86848fe017e990b96ca63e25af Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Tue, 22 Jan 2013 14:35:32 +0000 Subject: [PATCH] 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 --- .../apache/openjpa/meta/ClassMetaData.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java index cf37d747c..f71ddb89e 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java @@ -179,7 +179,7 @@ public class ClassMetaData private List> _interfaces = null; private final Map,Map> _ifaceMap = new HashMap,Map>(); - private int _identity = ID_UNKNOWN; + private Integer _identity = null; private int _idStrategy = ValueStrategies.NONE; private int _accessType = AccessCode.UNKNOWN; @@ -440,21 +440,25 @@ public class ClassMetaData * primary key fields, and {@link #ID_APPLICATION} otherwise. */ public int getIdentityType() { - if (_identity == ID_UNKNOWN) { - ClassMetaData sup = getPCSuperclassMetaData(); - if (sup != null && sup.getIdentityType() != ID_UNKNOWN) - _identity = sup.getIdentityType(); - else if (getPrimaryKeyFields().length > 0) - _identity = ID_APPLICATION; - else if (isMapped()) - _identity = ID_DATASTORE; - else - _identity = _repos.getMetaDataFactory().getDefaults(). - getDefaultIdentityType(); - } + if (_identity != null) { + return _identity; + } else { + ClassMetaData sup = getPCSuperclassMetaData(); + if (sup != null && sup.getIdentityType() != ID_UNKNOWN) + _identity = sup.getIdentityType(); + else if (getPrimaryKeyFields().length > 0) + _identity = ID_APPLICATION; + else if (isMapped()) + _identity = ID_DATASTORE; + else if (isAbstract()) + _identity = ID_UNKNOWN; + else + _identity = _repos.getMetaDataFactory().getDefaults(). + getDefaultIdentityType(); + } return _identity; } - + /** * The type of identity being used. This will be one of: *
    @@ -2511,8 +2515,9 @@ public class ClassMetaData _embeddable = meta._embeddable; _interface = (meta.isManagedInterface()) ? Boolean.TRUE : Boolean.FALSE; setIntercepting(meta.isIntercepting()); + _abstract = meta.isAbstract(); _impl = meta.getInterfaceImpl(); - _identity = meta.getIdentityType(); + _identity = meta._identity == null ? null : meta.getIdentityType(); _idStrategy = meta.getIdentityStrategy(); _seqName = meta.getIdentitySequenceName(); _seqMeta = null;