i am using hibernate for a application.I have two tables with many-many relationship and I have POJOs for both of them.But the relationship is defined in third table which doesnot have POJO.How can i relate my two tables and use them
i am using hibernate for a application.I have two tables with many-many relationship and
Share
Suppose you have POJO for TableA and TableB and want to associate many-to-many relationship between them in Table C without creating POJO for TableC.
If Table C ONLY contains two columns which have the foreign key constraint to Table A and Table B , you can achieve it by using the
@ManyToManyand@JoinTable:But if Table C contains more additional columns that have no foreign key constraint to other tables (such as the column for
last_modified_date) , you cannot do it and you must declare Table C as a POJO and model the many-to-many association as two one-to-many associations to Table C.