aspose file tools*
The moose likes Object Relational Mapping and the fly likes Data is not inserting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Data is not inserting" Watch "Data is not inserting" New topic
Author

Data is not inserting

Gyaneshwar Prasad
Greenhorn

Joined: May 30, 2006
Posts: 13
Hello There,
I am working with Hibernate and I am unable to insert any data into DB

-------------------------------------------------------------------------------

[hibernate.cfg.xml]

-----------------------------------------------------------------------------
[book.hbm.xml]

-----------------------------------------------------------------------------
[ mypkg/Book.java ]

-----------------------------------------------------------------------------
[ BookTest.java ]

-----------------------------------------------------------------------------
[ HibernateSession.java ]

------------------------------------------------------------------------------------
Here it is what I have in my whole program under "mypkg" package. I am using Hibernate2.1, MySQL4.1 and also I have all required class/jar files in my classpath, since I am working with Eclipse3.1.

I am getting only this message:

Hibernate: insert into books
(title, author, isbn, pagecount, copyright, cost) values (?, ?, ?, ?, ?, ?)

No Data at all !

Please help me in this context. Thanks in Advance.

[Edited to use code tags - Paul Sturrock]
[ October 03, 2006: Message edited by: Paul Sturrock ]
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
You need to call session.getTransaction().commit() before calling session.close() or set hibernate.connection.autocommit to true.
Gyaneshwar Prasad
Greenhorn

Joined: May 30, 2006
Posts: 13
Thanks Scott,
Sorry for replying too late. Its really working . thumb:
Thank again!
 
Don't get me started about those stupid light bulbs.
 
subject: Data is not inserting
 
Similar Threads
Session is closed
InvalidMappingException
problem with hibernate application
it is giving fatal exception
why it is inserting the values in the rows again