Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I insert value in another table  RSS feed

 
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: 3974
24
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!