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

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
M_Z

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

Post by M_Z »

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.

M_Z

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

Post by M_Z »

To make it a bit clear: Java type for a @Lob mapping can be any serializable type

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

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

Post by admin »

You are right. Option 2 is now modified to:
This class can be made a valid entity by annotating Address class with @Embeddable and annotating addr field with @Embedded.
Option D is now incorrect because annotating it with @Lob is not a must.

thank you for your feedback!

stiekemaj
Posts: 8
Joined: Sun Jan 25, 2015 6:08 am
Contact:

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

Post by stiekemaj »

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.
This is not true. The @Embedded annotation is optional. See the jpa 2.0 specs, paragraph 2.8:
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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest