This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

setFlushMode (FlushModeType.AUTO) vs FlushModeType.COMMIT

 
Ranch Hand
Posts: 1742
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: 1742
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: 1742
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: 1742
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!