• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt on enthuware answer (I)

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following question is from enthuware:


The correct answer is b)

Option a) is explained to be incorrect because it is not required that Address implements Serializable.
Unfortunately no explanation is given why Address must be annotated with @Embeddable.

In fact, JPA doesn't require each user defined type of a persistent field to be annotated with @Embeddable.

In my opinion either a) and b) are valid options to make the code work. For, according to JPA spec 2.1.1
serializable classes are valid types for persistent fields.





 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for Embeddable classes, it is not required to implement Serializble.

Other than that Address class, can be @IdClass.

But that option is not given. As per my understanding, the given answer is correct.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

for Embeddable classes, it is not required to implement Serializble.


That's correct. But there is a second option to extract fields into a separate class other than using
embeddable classes: Just take a serializable class as type of the field (the persistence provider
then stores the serialized object in the db). And this second option is given by a).

Of course, one can't say that Address class must implement Serializable (it can also be taken to be
a non-serializable embeddable class). But similar one can't say that Address class must be
embeddable (it can also be a serializable, non-embeddable class).

 
reply
    Bookmark Topic Watch Topic
  • New Topic