Page 1 of 1

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

Posted: Mon Feb 09, 2015 6:21 am
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.

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

Posted: Mon Feb 09, 2015 7:24 am
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.

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

Posted: Thu Sep 20, 2018 6:12 pm
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.

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

Posted: Thu Sep 20, 2018 8:49 pm
by admin
Added more clarification to the explanation.
thank you for your feedback!