About Question enthuware.oce-jpad.v6.2.525 :

Moderator: admin

Post Reply
swiss-chris
Posts: 11
Joined: Fri Jan 23, 2015 5:05 am
Contact:

About Question enthuware.oce-jpad.v6.2.525 :

Post by swiss-chris »

Note that Collections of non-serializable types must not be used as mapping type.
What does this mean and where can I find this requirement documented?

In your own list of requirements for persistant entity fields, you don't mention any requirements about collection types being serializable:
The persistent fields or properties of an entity may be of the following types:
Java primitive types; java.lang.String; other Java serializable types (including wrappers of the primitive types, java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar, java.sql.Date, java.sql.Time, java.sql.Timestamp, byte[], Byte[], char[], Character[], and user-defined types that implement the Serializable interface); enums; entity types; collections of entity types; embeddable classes; collections of basic and embeddable types.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.525 :

Post by admin »

The text that you've quoted itself says, "... other Java serializable types..." and "...user-defined types that implement the Serializable interface...".

You can check out section 2.2 of JPA 2.0 specification.
If you like our products and services, please help us by posting your review here.

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.525 :

Post by __JJ__ »

Note that Collections of non-serializable types must not be used as mapping type. However, since the question only asks about the type of the persistent attribute, this option is valid because the option does not have any generic type information.
This is misleading because it effectively says that you can't have a List<X> if X is not Serializable.
But if you read the spec:
The persistent fields or properties of an entity may be of the following types: ... entity types; collections of entity types; embeddable classes; collections of basic and embeddable types
it is clear that if X is either an entity or an embeddable you can have a List<X> without X being Serializable.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.525 :

Post by admin »

Added more clarification to the explanation.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests