Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,13 @@ private ClassMetaData parseClassAnnotations() {
break;
case ID_CLASS:
if (isMetaDataMode()) {
// Jakarta Persistence 3.2 (section 2.4.1) no longer requires
// the primary key class to be public or to implement
// Serializable, so neither is validated here; see
// OPENJPA-2940 and OPENJPA-2984. A non-serializable id
// class does still prevent serializing the identity
// object it is wrapped in, which detached entities,
// remote commit events and a distributed data cache do.
meta.setObjectIdType(((IdClass) anno).value(), true);
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
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;
Expand Down Expand Up @@ -1347,6 +1346,12 @@ protected boolean startIdClass(Attributes attrs)
} catch (Throwable t) {
throw getException(_loc.get("invalid-id-class", meta, cls), t);
}
// Jakarta Persistence 3.2 (section 2.4.1) no longer requires the primary
// key class to be public or to implement Serializable, so neither is
// validated here; see OPENJPA-2940 and OPENJPA-2984. A non-serializable
// id class does still prevent serializing the identity object it is
// wrapped in, which detached entities, remote commit events and a
// distributed data cache do.
meta.setObjectIdType(idCls, true);
return true;
}
Expand Down
25 changes: 14 additions & 11 deletions openjpa-project/src/doc/manual/jpa_overview_pc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -838,17 +838,7 @@ following criteria:
<itemizedlist>
<listitem>
<para>
The class must be public.
</para>
</listitem>
<listitem>
<para>
The class must be serializable.
</para>
</listitem>
<listitem>
<para>
The class must have a public no-args constructor.
The class must have a no-args constructor.
</para>
</listitem>
<listitem>
Expand Down Expand Up @@ -881,6 +871,19 @@ hierarchy mirrors the inheritance hierarchy of the owning entity classes (see
</itemizedlist>
<note>
<para>
Jakarta Persistence 3.2 no longer requires the identity class to be public or to
implement <classname>java.io.Serializable</classname>, and OpenJPA no longer
enforces either. An identity class that does not implement
<classname>Serializable</classname> can, however, not be used where OpenJPA has
to serialize the identity object it is wrapped in: serializing a detached
entity, remote commit events in a clustered configuration, and a distributed
data cache. Those fail with a
<classname>java.io.NotSerializableException</classname> naming the identity
class.
</para>
</note>
<note>
<para>
Though you may still create identity classes by hand, OpenJPA provides the
<classname>appidtool</classname> to automatically generate proper identity
classes based on your identity fields. See
Expand Down
Loading