Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • 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
Posts: 3953
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
 
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!