Hi All,
I have a basic question related to O/R mapping.
I have 3 tables, A, B and C.
Table A
A_ID int primary key
A_NAME varchar
Table B
B_ID int primary key
A_ID int foreign key to A.A_ID
B_NAME varchar
Table C
C_ID int primary key & foreign key to A.A_ID
C_NAME varchar
I want the beans A, B and C to be as follows:
Code:
class A
{
private int id;
private String name;
private B b;
private C c;
}
Code:
class B
{
private int id;
private String name;
}
Code:
class C
{
private int id;
private String name;
}
When I perform a select on A, I want to get the members b and c of A to be automatically populated based on the foreign key relations specified in the tables B and C.
I will always have 0 or 1 rows in B and C for every row in A. In other words, the relationship between A-B and A-C are one-to-one.
Can someone help me on achieving this?
Basically I want to know how to write the mapping file.
Thanks,
Jayarama Nettar.