::Relationship::
person(many) -> address(one)
::DB Schema::
person( personId, addressId )
address( addressId )
::Java Operation::
person.getAddress();
::Annotation::
@Entity @Table(name="PERSON") public class Person { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @ManyToOne @JoinColumn(name = "ADDRESS_ID") private Address address; public Address getAddress() { return address; } }
@Entity @Table(name="ADDRESS") public class Address { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; }
[Association Mapping List]
5 comments:
:) Very nice,
puting the DB Schema along with the java persisted code makes it much more clearer.
The role of each entity and how it is mapped in the relational schema.
is ADDRESS_ID name of the column in ADDRESS table?
no ADDRESS_ID is the name of the column in person table.
Nice and concise tutorial. I like it.
This is nice, would be great if you can add a pictorial representation to get table relations visibility.
Post a Comment