diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java index a35b5f89c..ce5b478f9 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java @@ -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) diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java index 3dc65495f..84974c807 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java @@ -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; } diff --git a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties index 41550d046..a963b490b 100644 --- a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties +++ b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties @@ -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. \ No newline at end of file