Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate SaveOrUpdate

 
Yogesh Kumar Yadav
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am new to Hibernate and facing very basic problem and not able to found what's issue in the code ......
I am updating an Employee data using the hibernateTemplate.saveOrupdate method ....but when i m calling get or load method its failing saying no row found ..
I am pasting my Code below ..



Employee class :

EmployeeDao

Thanks,

 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. You said, you are saving the data, Did you check if it is getting saved successfully or requires you to commit the transaction?
2. Did you actually run a query across the database and check if there are any rows with id "123"?
 
Yogesh Kumar Yadav
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply ...

Yes I did check the database after the save ..I can see the data......However when i m running the code after commenting the saveOrUPdate , just to fetch the
values ...I am getting no rows and same is applicable when i m looking into the database ...

I know the problem is because of commit ...but where I need to put the commit info ??

Thanks for helping
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the hibernate config file, you can specify this option.

hibernate.connection.autocommit - Enables autocommit for JDBC pooled connections (it is not recommended). e.g. true | false

for more information,

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic