Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Having problem with inserting data into table using hibernate

 
Varun Nayudu
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I am having trouble with adding data into the database using hibernate .I have got a table 'ln_user_group' which has 2 columns 'userid,groupname'. Both these fields act as a primary key

The Hibernate mapping file is as follows



I am using netbeansIDE and it automatically generates 2 POJO's of the table 'ln_user_group'

The 2 POJO's a given below..



And the other one is


Now i understand it creates 2 pojo's for generating a unique id , but i want to know how do i add data into this table 'ln_user_group'

My code for adding data into table is as follows:



but i don't thing it will work. Can any one please tell me the write way to add data into this table
 
Arpit Purohit
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The approach to use given auto generated classes to add record should be as follows:

 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
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!