Both uni direction and bi direction
a.one-to-one
b.one-to-many
c.many-to many
A.one-to-one Relationship can be achieved in 3 ways.
1.Join Table ( separte table to maintain reationship)
2.Foreign Key ( relationship mainted in same table with foreign key)
3.Primary Key Column ( table 1 primarykey is user to retrieve table 2 primary key, if table 2 entity is updated separatly it's not the correct solution.It's applicable only for one to one.
B.one-to-Many:-
1.Join Table
2.foreign Key
You don't have to (must not) define any physical mapping in the mappedBy side.
C.Many-to-Many
1.Only Join Table
a.one-to-one
b.one-to-many
c.many-to many
A.one-to-one Relationship can be achieved in 3 ways.
1.Join Table ( separte table to maintain reationship)
2.Foreign Key ( relationship mainted in same table with foreign key)
3.Primary Key Column ( table 1 primarykey is user to retrieve table 2 primary key, if table 2 entity is updated separatly it's not the correct solution.It's applicable only for one to one.
B.one-to-Many:-
1.Join Table
2.foreign Key
Hibernate strongly advise you to use a join table for one-to-many kind of association
You don't have to (must not) define any physical mapping in the mappedBy side.
C.Many-to-Many
1.Only Join Table
No comments:
Post a Comment