Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes I'm not able to insert record in Derby using Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "I Watch "I New topic
Author

I'm not able to insert record in Derby using Hibernate

Sanjeev Kumaar
Greenhorn

Joined: Jun 10, 2010
Posts: 12

Hi All!

This is my first example of Hibernate. I'm trying to insert a record in Derby using Hibernate. I've created a web application where a servlet is doing the main stuff.

I've used
IDE : Netbeans 6.8
Database : Derby
Server : Glassfish



here is my hibernate.cfg.xml



my hibernate.reveng.xml



my pack1.Student.hbm.xml




my pack1.Student.java




my pack1.NewHibernateUtil.java




n my pack1.NewServlet.java




I'm having STUDENT table inside "sample" db on my local Derby server.




while calling servlet it shows success but doesn't inserting record .

Please guide me.

Thanks in advance.


SCJP 5, SCWCD
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Where do you commit your transaction?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Sanjeev Kumaar
Greenhorn

Joined: Jun 10, 2010
Posts: 12


Thanks Paul for showing interest ,

as per tutorial saving the session was enough and I if committing the transaction is necessary then how I'll do this ? I mean which method I'll use?

Sanjeev Kumaar
Greenhorn

Joined: Jun 10, 2010
Posts: 12


Problem resolved ....

I modified my servlet code a bit like following.





Tell me if I can improve this ...


Thanks Paul ! you were really helpful .
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Sanjeev Kumaar wrote:
Thanks Paul for showing interest ,

as per tutorial saving the session was enough and I if committing the transaction is necessary then how I'll do this ? I mean which method I'll use?



You are welcome.

The tutorial you are using is wrong.
 
 
subject: I'm not able to insert record in Derby using Hibernate