I disagree with existing answers:
1) I selected option A as correct. Although it's not clear if the Employee is detached and sent via network, it's fine.
2) I disagree with option B, which says if Address marked as Embeddable, then Employee valid entity. To be a valid entity, Employee also must mark addr with @Embedded. Otherwise application will fail.
3) I selected option D as correct, because Employee in current state is invalid - Address is not a basic type (persistence provider does not know how to process by default), so to make it persistable we must give some idea to persistene provider, one of the possible ways - make Address serializable (we don't know it from question, but based on option A we can assume that Employee and Address will be serializable) and annotate with @Lob. Option D is more realistic than option B, because option B clearly invalid without mentioning @Embedded.
My choice is options A and D.
About Question enthuware.oce-jpad.v6.2.548 :
Moderators: Site Manager, fjwalraven
Re: About Question enthuware.oce-jpad.v6.2.548 :
To make it a bit clear: Java type for a @Lob mapping can be any serializable type
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.548 :
You are right. Option 2 is now modified to:
thank you for your feedback!
Option D is now incorrect because annotating it with @Lob is not a must.This class can be made a valid entity by annotating Address class with @Embeddable and annotating addr field with @Embedded.
thank you for your feedback!
-
- Posts: 8
- Joined: Sun Jan 25, 2015 6:08 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.548 :
This is not true. The @Embedded annotation is optional. See the jpa 2.0 specs, paragraph 2.8:M_Z wrote:I disagree with existing answers:
2) I disagree with option B, which says if Address marked as Embeddable, then Employee valid entity. To be a valid entity, Employee also must mark addr with @Embedded. Otherwise application will fail.
If a persistent field or property other than a relationship property is not annotated with one of the map- ping annotations defined in Chapter 11 (or equivalent mapping information is not specified in the XML descriptor), the following default mapping rules are applied in order:
- If the type is a class that is annotated with the Embeddable annotation, it is mapped in the same way as if the field or property were annotated with the Embedded annotation. See Sec- tions 11.1.13 and 11.1.14.
Who is online
Users browsing this forum: No registered users and 19 guests