• 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

Debugging hibernate

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

i work with Ejb3 (jboss + hibernate).
i get an excpetion when i tried to execute query because hibernate execute flush before the query and in the flush it complained that it try to persist deleted object. (i dont get any furher information)
I debug my code and i dont call to any persist during this sequence (there is also no case of changes that can cause to cascade).

I have JAD plugin in my eclipse and i put a breakpoint in the hibernate class , but it didnt stop.

Please help me to think on any idea to understand which object it try to persist.

ps. hibernate trace didnt help.
Thank you
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So it would all occur in the midst of a "transaction/session". Can you post that code?

Mark
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, i cant post the code becaus this is a long a nd complex dequence.

I know that it difficult to give solution without code , but if you can think on tips on how to debug this issue i will be greatfull.
i set hibernate log to trace , but there are no inforamtion.
I need to know which object it try to persist. (i dont call to persist, i guess its due to cascade)

Thak you
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I can't help you with your exact code. So all I can do is give some basic advice.

1. Keep your Hibernate Sessions short. The longer you keep them open the more full the Session gets holding all the objects that it is managing in multiple Maps, so the more you put in there, the bigger the memory it takes up. Also, the tougher it becomes to debug and figure out what is happening to those objects that Hibernate is managing. Your example is a perfect example. At some point in your code your remove an object that is being managed by Hibernate, that Hibernate now has as an object to be removed, and then you try to persist it, which Hibernate already knows that it was removed and that you can't persist a removed object.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try turning on show_sql to see what statements Hibernate is trying to run in the flush.

Basically a flush, will go through the managed objects and persist or delete the objects that have changes. So when an object is managed by a Hibernate session it tracks all the changes you do, so even if you don't have a session.saveOrUpdate() anywhere, something as simple as myObject.setSomeValue(value), will be tracked and Hibernate knows when it flushes that a statement will need to run against the database, this could be an insert, update, or delete.

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic