Page 1 of 1

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

Posted: Fri Mar 16, 2012 3:26 pm
by M_Z
The explanation is not completely correct, this already was discussed here: viewtopic.php?f=4&t=950

In case of "orphanRemoval=true" the "remove" is not necessary, just commit of transaction will remove the Address:

Code: Select all

Person p = (Person) em.find(Person.class, 1); //find the person with address
Address a = p.getAddress(); //an Address entity also exists for this person
p.setAddress(null);
// NOT NEEDED a.setPerson(null);
// NOT NEEDED em.remove(p); 
<commit at some time>

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

Posted: Fri Mar 16, 2012 5:21 pm
by admin
There is a little difference between both the questions. In the explanation given in this question, situation 2 is talking about the case when orphanRemoval=true is NOT present and so once you remove the link from person to address, and if you then remove person, address will not be deleted.

In the other question, orphanRemoval=true is the right option.

HTH,
Paul.

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

Posted: Mon Sep 24, 2012 2:06 pm
by jszczepankiewicz
Not sure but the code is probably not complete:
there is no @OneToOne annotation on address and Address is not Serializable

so correct me if I'm wrong but according to some other questions in this quiz bank this is not correct mapping and at least will generate JPA vendor warning.

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

Posted: Wed Sep 26, 2012 5:46 pm
by admin
It is explicitly given in the question that there is a unidirectional one to one mapping between the two. So even if there is no annotation, it can be safely assumed that this information is present in the deployment descriptor.

Yes, an entity should implement Serializable. But it is a standard practice to ignore it even in the real exam.

HTH,
Paul.