Page 1 of 1

About Question enthuware.oce-jpad.v6.2.552 : Test 1 :question 55

Posted: Wed May 01, 2013 10:35 am
by sudhakarbe
Given that the following method has just been executed, identify the correct statement(s).

public void updateAll() {
Customer cust = em.find(Customer.class, 1); cust.setStatus("normal");
Query q = em.createQuery( "UPDATE Customer c SET c.status = 'outstanding'");
q.executeUpdate();
System.out.println(cust.getStatus());
}


Could you explain why this answer is wrong
cust.getStatus() will return "outstanding".

Re: About Question enthuware.oce-jpad.v6.2.552 : Test 1 :question 55

Posted: Wed May 01, 2013 4:39 pm
by admin
As the explanation says, "Bulk updates are not reflected in the existing persistence context. So it will return "normal"."

You are going directly to the database and updating the values. These changes will not be reflected in the loaded entities until you refresh them.

HTH,
Paul.

Re: About Question enthuware.oce-jpad.v6.2.552 : Test 1 :que

Posted: Sun Aug 30, 2015 12:01 pm
by romsky
I think the 2nd(correct) variant is somehow misleading. The status will be updated, that is clear,
but which update we are talking about, there are two updates? In memory(by cust.setStatus("normal")) or in database(by bulk update).

I think it should be : "their status will be updated in database as well."

Re: About Question enthuware.oce-jpad.v6.2.552 : Test 1 :que

Posted: Sun Aug 30, 2015 8:30 pm
by admin
The option has been updated to make it clear that it is talking about the bulk update.
thank you for your feedback!