This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Data getting saved in session, but not being persisted in table. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Data getting saved in session, but not being persisted in table." Watch "Data getting saved in session, but not being persisted in table." New topic
Author

Data getting saved in session, but not being persisted in table.

mara thamizhan
Ranch Hand

Joined: Jul 05, 2006
Posts: 74
Dear dudes,
In persisting data in MySQL through hibernate, i'm using a simple java class , which creates an instance of my form , sets data , reads the configuration file, builds a session factory i.e. hibernate.cfg.xml , opens the session and save data .
Actually data was not inserted into the table eventhough i'm getting the message similar to that.

I created the database in MySQL initially.
message console:


My java application:"Testinghibernate.java"




Information.java


hibernate.cfg.xml:



Information.hbm.xml:
mara thamizhan
Ranch Hand

Joined: Jul 05, 2006
Posts: 74
will someone please reply?
jayachandra madopothula
Greenhorn

Joined: Jan 08, 2008
Posts: 4
Possible corrections you have to have work
1.If you are working in eclipse please check the application structure
2. remove the and run it.
jayachandra madopothula
Greenhorn

Joined: Jan 08, 2008
Posts: 4

see the structure shown in the picture.

after arranging the whole structure just update resource mapping tag in hibernate.cfg.xml with absolute path of the hbm.xml
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Hibernate requires a Transaction, and it to be commited to actually save stuff to the database. I do not see a

Transaction tx = session.beginTransaction();

and I also don't see a

tx.commit();

in your code.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Vikky Bali
Greenhorn

Joined: Jun 07, 2007
Posts: 1
Using Transaction it is working but Is this mandatory to use transaction in Hibernate ?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Data getting saved in session, but not being persisted in table.