This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate Cannot insert values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Cannot insert values " Watch "Hibernate Cannot insert values " New topic
Author

Hibernate Cannot insert values

Steve James
Ranch Hand

Joined: Apr 12, 2009
Posts: 44
Tried for 3 hours can't find a answer , posting it

After running the program printing Inserting Record and Done inserting values , but couldn't find values in db . Any help what to check and where to check ?






Pojo class :

package mine;
// Generated Apr 18, 2009 10:56:39 AM by Hibernate Tools 3.2.1.GA





I am just a brick in the wall of Java
Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
hi,

I'm not an Hibernate expert, but there is one very important thing that I think your code is missing:
you're neither beginning, closing a Transaction nor committing your insert. Therefore Hibernate keeps the object you created in its object cache.
Try something like this:



except that you should obviously do your object creating instead of doing a select in lines 6-11

(taken from laliluna)
Steve James
Ranch Hand

Joined: Apr 12, 2009
Posts: 44
joe that worked . Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate Cannot insert values
 
Similar Threads
Hibernate exception problem
NullPointerException in hibernate
Basic hibernate code explanation
org.hibernate.exception.GenericJDBCException
Problem with running my first Hibernate App