• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not able to build session object in hibernate

 
Prateek Saxena
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty new to hibernate. I've been trying to add some data to an existing table in mysql database using hibernate. But there is an error in my code. The session object is not being built. My code is as below:

add_user.java:



Users.java :




hibernate.cfg.xml:



users.hbm.xml:



The stack trace is as follows:


Can someone please help me. I've no idea why this is happening.


 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prateek,


Can you please refer this link where in ServiceLayer you can see how session is being created and later a commit.


example1


and refer this below link.. create a transaction

example2


I hope that helps.




 
Prateek Saxena
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply Dhwani. I've already implemented the changes you have mentioned. The project is working now. Apparently, it was an issue with conflicting jars. It's been sorted out now.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!