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

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
sudhakarbe
Posts: 1
Joined: Wed May 01, 2013 10:33 am
Contact:

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

Post 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".

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

romsky
Posts: 39
Joined: Thu Jan 29, 2015 4:49 pm
Contact:

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

Post 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."

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

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

Post by admin »

The option has been updated to make it clear that it is talking about the bulk update.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests