Add a warning when complex id class is non-serializable

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1469643 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2013-04-19 00:07:41 +00:00
parent 8b75df3c9b
commit 1a1ab83ff5
3 changed files with 11 additions and 1 deletions

View File

@ -599,8 +599,13 @@ public class AnnotationPersistenceMetaDataParser
warnFlushMode(meta);
break;
case ID_CLASS:
if (isMetaDataMode())
if (isMetaDataMode()) {
Class<?> idClass = ((IdClass)anno).value();
if (!Serializable.class.isAssignableFrom(idClass)) {
_log.warn(_loc.get("id-class-not-serializable", idClass, _cls).toString());
}
meta.setObjectIdType(((IdClass) anno).value(), true);
}
break;
case NATIVE_QUERIES:
if (isQueryMode() && (meta.getSourceMode() & MODE_QUERY)==0)

View File

@ -21,6 +21,7 @@ package org.apache.openjpa.persistence;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
@ -1266,6 +1267,9 @@ public class XMLPersistenceMetaDataParser
} catch (Throwable t) {
throw getException(_loc.get("invalid-id-class", meta, cls), t);
}
if (!Serializable.class.isAssignableFrom(idCls)) {
_conf.getConfigurationLog().warn(_loc.get("id-class-not-serializable", idCls, _cls));
}
meta.setObjectIdType(idCls, true);
return true;
}

View File

@ -256,3 +256,4 @@ EntityManagers this property should not be used because these EntityManagers may
time.
shared-cache-mode-take-precedence: The DataCache is set to {0} while the shared-cache-mode Element or \
javax.persistence.sharedCache.mode property is set to NONE. The shared-cache-mode takes precedence and caching is disabled.
id-class-not-serializable: The composite identity class "{0}" for entity "{1}" is not serializable.