• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate - PreUpdateEventListener - Locks Table

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys

This code works perfect for one appliction where JTA is used.
The second applictian I am attempting to get this code working in, freezes on the last line. The underlying DB in both cases is SQL Server 2008
What happens is that Hibernates locks the table on the database. I have to release the lock in the DB.



This code takes the item in the DB and compare withs the pue.getEntity(). pue.getEntity() holds the changed entity about to be persisted
This is for auditing purposes.

Now the issue is Hibernate persists the item first with the primary key and with blank fields
Then does an update to fill in the blank fields. So this is all happening in the 1 transaction
(I dont know why - this is hibernate behaviour and hence why im falling into onPreUpdate after onPreInstert)



The second app has the following code to manage transaction handling instead of using JTA. (Glass fish V2 is the server)


onPreUpdate is entered on trx.commit()
Please help. Does my database pool on glassfish need a particular set up
Should I use LockMode when doing retrieve
retrieveSession.get(pue.getEntity().getClass(),Long.valueOf(entityStringID),LockMode.NONE);

I have tried various changes but cant nail it

Alan
 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic