This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

setFlushMode (FlushModeType.AUTO) vs FlushModeType.COMMIT  RSS feed

 
Ranch Hand
Posts: 1733
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
For EntityManager or TypedQuery, what is the difference between FlushModeType.AUTO and COMMIT.
I have been reading the explanation from the book. But I still don't get it.
Thanks in advance.
 
Himai Minh
Ranch Hand
Posts: 1733
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to do this code with both FlushTypeMode = AUTO and COMMIT, but the outputs on the screen of the messages are the same:


Message 13 is the same before the flush mode is set to either Auto or commit and after the flush mode is set.


13 : Does EJB 3.0 support inheritence? : Mon May 22 23:47:34 EDT 2006 : ACTIVE

 
Himai Minh
Ranch Hand
Posts: 1733
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have no luck with this MessageBoardServlet to demo the difference between FlushModeType.COMMIT vs FlushModeType.AUTO.
But I found a luck with the bulkQueryExample in the same chapter.



//Sarah's manager is updated from Joan to Roberts' after the query is executed.
//The change happened in changeManagerForSarah is not committed.
direct employee of id 12 Roberts' : Sarah
direct employee of id 12 Roberts' : John
direct employee of id 12 Roberts' : Roberts
direct employee of id 12 Roberts' : Peter
direct employee of id 12 Roberts' : Marcus
direct employee of id 12 Roberts' : Roberts'

//Now, the changeManagerForSarah is committed. Her department is 3 with manager Dummy.
Employee 2 Sarah  has manager : 21



Refer to the screen shots of my DB.
sarahManagerIsJoan.JPG
[Thumbnail for sarahManagerIsJoan.JPG]
Department 2 has manager Joan, Sarah is in this department
updateScreen.JPG
[Thumbnail for updateScreen.JPG]
Update department 2
SarahInDept3withDummy.JPG
[Thumbnail for SarahInDept3withDummy.JPG]
Commit Sarah
 
Himai Minh
Ranch Hand
Posts: 1733
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code remains the same as the above example except the FlushModeType is AUTO, not COMMIT.



 //Sarah's manager is changed from Joan to Dummy at first and the em automatically flushes the change to the DB
//Now, Sarah's manager is not changed from Joan to Roberts then to Dummy.
direct employee of id 12 Roberts' : John
direct employee of id 12 Roberts' : Roberts
direct employee of id 12 Roberts' : Peter
direct employee of id 12 Roberts' : Marcus
direct employee of id 12 Roberts' : Roberts'
Employee 2 Sarah  has manager : 21

originalEmployeeTable_autoFlushMode.JPG
[Thumbnail for originalEmployeeTable_autoFlushMode.JPG]
Department 2 is supervised by Joan originally
committedEmployeeTable_autoFlushMode.JPG
[Thumbnail for committedEmployeeTable_autoFlushMode.JPG]
Sarah is in deparment 3 supervised by Dummy
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!