This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@PrePersist Synchronizing

 
Mohammad Jaber
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
iam using JPA with Hiberante provider , How can i ensure that @PrePersist and the "Peristing" process to be executed in synchronized mode , i mean i don't wont other thread to execute @PrePersist before the previous one has already saved into DB , is this supported By JPA by default or is there any extras i should do , Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure about synchronization here, but do you know about ThreadLocal. Please check the following : http://www.hibernate.org/hib_docs/entitymanager/reference/en/html_single/#transactions-basics-uow
 
Mohammad Jaber
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Iam already using ThreadLocal but my case is that i want to fetch the Id (Max + 1) from the DB during the PrePersist and i want to make sure that no other thread will intrupt this by fetching the same value from the DB , Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic