This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Having problem with inserting data into table using hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Having problem with inserting data into table using hibernate" Watch "Having problem with inserting data into table using hibernate" New topic
Author

Having problem with inserting data into table using hibernate

Varun Nayudu
Ranch Hand

Joined: Jun 26, 2006
Posts: 157
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

SCJP 1.5, SCWCD 1.5
Arpit Purohit
Greenhorn

Joined: Jan 09, 2007
Posts: 21
The approach to use given auto generated classes to add record should be as follows:


Regards,
Arpit Purohit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Having problem with inserting data into table using hibernate
 
Similar Threads
Error when inserting data in hibernate
Problem mapping pojo with view using hibernate
hibernate composite key problem
Adding data using hibernate for Composite primary keys
Problem with inserting new data into database using hibernate