Win a copy of 97 Things Every Java Programmer Should Know 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

setFlushMode (FlushModeType.AUTO) vs FlushModeType.COMMIT

 
Ranch Foreman
Posts: 1897
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 Foreman
Posts: 1897
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 Foreman
Posts: 1897
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 Foreman
Posts: 1897
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
 
Looky! I'm being abducted by space aliens! Me and this tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic