java - How to create and add data to Table 3 without adding data to Table 1 and Table 2 in hibernate -
i new hibernate , not able find out way of situation have. kind of many many relationship difference want data inserted in table 3 , not in table 1 & table 2.
table 1 , table 2 has data present.
current requirement:
table 1 has user id, first name, last name (already exists) table 2 has document id, document name, document content (already exists) table 3 should have user id , document id both table 1 & table 2 has data prepopulated. if user views document, want make entry in third table without persisting or updating in table 1 & table 2. want maintain data on documents viewed user when user logged off , login can show him docs unread. best use of hibernate in situation?
you don't need update people nor document table. hibernate able add entries third table (the join table) if configure right. annotate collection @manytomany , make sure working entities db instead of creating new ones:
- load person db
- load document db
- put document list of person
- save person entity
see here: http://www.mkyong.com/hibernate/hibernate-many-to-many-relationship-example-annotation/ walkthrough
Comments
Post a Comment