-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Object is not saved
PostPosted: Wed Jan 25, 2006 10:25 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
I use spring's getHibernateTemplate().save(Object obj).
However, Iam not able to save the object.

I use MySQL and my table uses an auto increment for the primary key field. In my hbm i have specified the generator calss as native.

However though the new row is not updated, MySQL seems to remember the number of attempts I had on creating the new row.
Because after trying multiple times (say 5) to insert using "hibernateTemplate" of Spring, when I try to manually enter the row values the id generator of MySQL sets the id value >5 times the old value.

Is it problem with Spring framework leveraging Hibernate or is it a problem with Hibernate itself?

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 25, 2006 11:23 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Sounds to me like you're not commiting the transaction. Are you using a TxInterceptor in Spring?

Post the spring beans wiring and the code you use in the getTemplate...


Top
 Profile  
 
 Post subject: Re: Object is not saved
PostPosted: Wed Jan 25, 2006 11:25 am 
Newbie

Joined: Thu Oct 14, 2004 2:48 pm
Posts: 4
If your save calls change the the auto increment column values and no data is being saved probably the transactions are not being commited.

What type of MySQL tables are you using ?
Some MySQL table types (like MyISAM) does not support transactions - you should configure your JDBC connetions to auto-commit.
Also some MySQL execution modes also does not support transactions.
For a full MySQL transactional support the make sure you´re are executing MySQL at MAX execution mode and use InnoDB table types.

If everyting is right with MySQL maybe the Spring framework is not configured to manage your transactions.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 5:03 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
Thanks Guys.
My Method calls from the DAO's was not wrapped by the Spring's TXn method interceptors.

I set my Txn interceptors with the target as MyDAO and it was done.
I thought that the call to the getHibernateTemplate would set me up with the TXn interceptors and I don't have to specify it explicitly.

It' s fine now.
Thakis a lot. :-)

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.