• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Hibernate Issue

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

I have an application that's been running for over a year now. I am using jaxb/hibernate. Recently I am running into an issue where Hibernate is not saving the data to the tables. The data does exists as I do see it in the logs but somehow hibernate is not able to save it. Most of the time it saves but once in a while it does not save and I don't get any errors or exceptions. Anyone experienced this before and knows what might be wrong. How to debug this as I don't get any errors or exceptions. There's nothing changed in the application.

Thanks
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think Hibernate is guilty.
Does your database support huge counts of records (or even a heavy load) ?
 
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
"There's nothing changed in the application."

What about the database, its location, IP address, anything. Something must have changed.

Maybe the network is having issues.

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

Yes we have an Oracle database and it does support huge counts of records plus there is no issue with the load either. It's been working fine at peak times. I tested this off peak hours too and I sometimes get those errors. So really don't where exactly is this error happening and hiberante succeeds but no data loaded and no errors either.

Thanks
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is hibernate issuing SQL to the database to store the objects? You have logging on?
 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is the snippet of the code where a save is done:



I am using jaxb and data is loaded in java objects from xml. payLoadData is the root class. Before saving I did checked if the root class does contain data and the data does exists. But some how hibernated never saves it to the database. I tried the same file several times and most of the times it works but sometimes it just does not insert any data. That's why I am little confused on what exactly is wrong. Thanks for any help.
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do you have sql debugging enabled on hibernate so you can see the sql commands hibernate is issuing to the database?
 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I enabled the sql debugging too but don't see anything unusual it's that hibernate commits everything fine but never see the data in the database. I again tested it multiple times with the same data and once a while it just does not save the data. Any ideas what else I can look at. Am using Oracle DB for back-end storage.

Thanks
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Boota:
Hi,

I enabled the sql debugging too but don't see anything unusual it's that hibernate commits everything fine but never see the data in the database. I again tested it multiple times with the same data and once a while it just does not save the data. Any ideas what else I can look at. Am using Oracle DB for back-end storage.

Thanks



I can not tell from your vague statement if hibernate is in fact issuing SQL commands to your database to store your data, or not!?

I assume you see the log entries for the save call, but I need to know if Hibernate has decided that the data needs to be saved and does so, or if Hibernate has decided this object is not changed and does not require an update. Or maybe you have no persistence by reachability or something else is happening.
 
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
Are you calls going through EJBs or something else that would create a Transaction, outside the Hibernate scope, that Hibernate is joining that transaction, and that after saving, something goes wrong in that outside transaction, and that transaction is rolled back, causing Hibernate to also rollback?

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

Here is what' happening. It's a Web Service where I am using hibernate to save the data. A client of the Web Service may send same data over. Now how do I make sure hibernate does save it even if the data is coming over again.

The first step is it validates the data, then it stores the payload in different tables and that's where it's not working (some times it works sometimes it basically does not save and no errors either at save time), then finally it stores the whole payload i.e. xml in one table as a clob and this always works fine, and finally Web Service returns the response to the client.

I never do an update it's always an insert. There is not transaction or ejb's involved it's a straight Web Service. I'll try to debug more but right now am kind of stuck and don't know what else I can look at.

Thanks for the help.
 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using Don't know if changing it to what will be the effect. Also what if I use merge instead of save when trying to persist the object.

Is there any difference between using cascade=none|save-update and using merge instead of save. Just trying to see what other options I have as I right now I am stuck and really can't figure out what's going on.

Here is the current code snippet where I am saving the object to the databse:



It randomnly does not save the data, I even tried the same file over and over. Any help is appreciated.

Thanks.
[ March 06, 2007: Message edited by: Mike Boota ]
 
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
Cascade options and merge aren't the same thing.

Cascade options are in regard to what Hibernate should do with related objects. So if I have a relationship between a and b, a has an instance of b. In the mapping for a, there is a relation mapping to b, in that mapping the Cascade option of none would mean when I do save(a) nothing is done with the b it holds. Even if b is changed, new or anything.

Merge is for detached objects and reattaching them to be managed by the Session.

So at this point, can you post your hibernate.cfg.xml (hide your username/password), you mapping hbm.xml files (Or classes with Annotations) and your HibernateUtil class code.

Thanks

Mark
 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following are the hbm, hibernate.cfg.xml , and Util Class code. Notification is the root class.





Thanks
 
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
Wow, lots of stuff.

Is it

session.save(notification);

or session.save(data);

that is your code. In one post I see "data" and in the last one I see "notification". probably not the issue, but confusing to me.

I don't see anything in your mapping that looks weird, but there is lots to it. Your HibernateUtil is a bit older ways of doing things, as you can now call getCurrentSession from the SessionFactory, but you might be using Hibernate 2.x instead.

Anyone else see anything to help Mike out?

Mark
 
Forget Steve. Look at this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic