This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

setFlushMode (FlushModeType.AUTO) vs FlushModeType.COMMIT

 
Ranch Hand
Posts: 1756
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: 1756
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: 1756
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: 1756
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
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!