IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes @PrePersist Synchronizing Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "@PrePersist Synchronizing" Watch "@PrePersist Synchronizing" New topic
Author

@PrePersist Synchronizing

Mohammad Jaber
Ranch Hand

Joined: Apr 10, 2006
Posts: 46
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


OCP , SCJP 5.0
Christophe Verré
Marshal

Joined: Nov 24, 2005
Posts: 14361

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


[SCBCD Wall of Fame] [My Blog]
All roads lead to JavaRanch
Help Japan. Make a donation.
Mohammad Jaber
Ranch Hand

Joined: Apr 10, 2006
Posts: 46
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
 
 
subject: @PrePersist Synchronizing
 
Threads others viewed
When do ejb 3 entity bean get/set methods get called
Practical usages of PrePersist() & PostPersist()
How can I return empty entity bean
entity Boolean field default value
JodaTime Map
IntelliJ Java IDE