Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is this EJB 3 bulk insert/persist or this will reduce the network traffic?  RSS feed

 
c shan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to EJB 3.0 , I am working on project which involves more than one insert ( entity-manager persists ) for child records.

I know batch update ,I tried for batch inserts using following method. After reading more about flush ie If the flush mode is set to COMMIT, the persistence provider will
only synchronize with the database when the transaction commits
.

So, after for following code there will be only one call from ejb container to sql server for n inserts, this will also reduce the network traffic too.
Please let me know your comments.




 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, flushmode COMMIT is really more of a hint that the provider should not flush until commit, there are no guarantees.
Second, setting the flushmode is not going to guarantee that you are going to get a single trip to the database. Once flushing occurs (for example at commit time) then there may be any number of database trips occurring, depending upon what the provider needs to do, and I highly doubt any provider would actually batch multiple persist calls of the same object type into a single SQL statement.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!