This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Entity Manager flush() doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Entity Manager flush() doubt" Watch "Entity Manager flush() doubt" New topic

Entity Manager flush() doubt

Aditya Vasudeva
Ranch Hand

Joined: May 27, 2008
Posts: 76
I have a question i cant answer :

A Java Persistence application uses the EntityManager.flush method to synchronize the current
persistence context with the database. Which two statements are correct? (Choose two.)

A. The flush method might cause the persist operation to be cascaded to related entities.
B. Extensive use of the flush method decreases the performance of a Java Persistence
C. The flush method should be used to synchronize the current persistence context with
modifications made in other transactions.
D. The flush method should be used to publish changes done in the current persistence context
to other transactions before actual transaction commit

What should the answers be ? Should'nt one of them be option D??
Please explain as to why you chose your options...
Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
the flush operation makes effective any pending entity manager operation.
But if you are working into a transaction, that effectiveness is not seen by other transactions until commit.
I would exclude the C option, too for obvious reasons.

SCJP<br />SCWCD 1.4 Upgrade (Remember: me stupid)<br />SCWCD 1.4<br /><a href="" target="_blank" rel="nofollow">SCBCD 5.0</a><br /><a href="" target="_blank" rel="nofollow">SCBCD 5.0 mock exam</a> <br /> <br />SCEA 5 Part1: Preparing...
Vinay Nath
Ranch Hand

Joined: Jul 06, 2008
Posts: 85
I would say B and D,

A, I m not sure about it. but C, I agree with Mirko.

SCDJWS 5.0, SCBCD 5.0, SCWCD 5.0, SCJP 5.0
Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
Surely! A and C are incorrect.
A is incorrect because of what I have written in my previous message.
[ July 14, 2008: Message edited by: Mirko Bonasorte ]
krishna bulusu
Ranch Hand

Joined: Aug 28, 2006
Posts: 185
flush() would make the entity synchronize with the database. So, How C and D comes into picture.
A is one Answer. But I don't think C and D are correct. So, B may e the other Answer.
Am I correct?

Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
Excuse me,
I have made confusion with another post.
Sure, C and D are incorrect.
I agree. Here's the link:
subject: Entity Manager flush() doubt
It's not a secret anymore!