aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate SaveOrUpdate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate SaveOrUpdate" Watch "Hibernate SaveOrUpdate" New topic
Author

Hibernate SaveOrUpdate

Yogesh Kumar Yadav
Greenhorn

Joined: Jan 09, 2010
Posts: 7
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

Joined: May 16, 2005
Posts: 513

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"?


If you are not laughing at yourself, then you just didn't get the joke.
Yogesh Kumar Yadav
Greenhorn

Joined: Jan 09, 2010
Posts: 7
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

Joined: May 16, 2005
Posts: 513

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate SaveOrUpdate