• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I insert value in another table

 
Gaurav Sandil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having three tables:

USER-TABLE: Here USER-ID is the primary key.

PROJECT-DETAIL-TABLE: Here PROJECT-ID is the primary key.

PROJECT-REL-TABLE: Here USER-ID and PROJECT-ID is the composite key.

PROJECT-REL-TABLE is the relationship table between USER-TABLE and PROJECT-DETAIL-TABLE.

I have made an application with Spring and hibernate where I am inserting the data in PROJECT-DETAIL-TABLE.

USER-TABLE already has the data which includes USER-ID. Now I want to insert the USER-ID and PROJECT-ID to PROJECT-REL-TABLE.

How can I achieve this using Hibernate.

Please help me out. Its very urgent.

 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its very urgent.

Please read -> EaseUp.

In general a many-to-many relationship is implemented through two one-to-many relationships from the related entities. So your Project detail entity and User entity will have to model in that way. An example here
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic