H
hilz
Sorry for posting this again. I posted it earlier in c.l.j.databases
and i did not get any replies. so i am posting the same question here,
hoping someone will answer.
thanks, and agian, sorry for doing that.
Hi all:
If i have two tables in an existing database, with a relation one-to-many
(one GROUP to many ITEMs)
table GROUP has columns:
ID (long, primary key)
NAME (string)
table ITEM has columns:
ID (long, primary key)
GROUP_ID (long, foreign key)
NAME (string)
ITEM_COST (double)
I want to design POJO classes "Group" and "Item" that map to these tables
my question is about the "Item" class:
should the "Item" class contain a field "groupId" of type Long, with its
getter and setter, or just a reference to a Group object, or both?
for example:
publie class Item{
..
..
Group group; //this?????
public Group getGroup(){return group;}
publie void setGroup(Group group){this.group = group;}
..
..
Long groupId; //or this??????
public Long getGroupId(){return groupId;}
public void setGroupId(Long groupId){this.groupId = groupId;}
..
..
// or both??????
}
thanks
hilz
and i did not get any replies. so i am posting the same question here,
hoping someone will answer.
thanks, and agian, sorry for doing that.
Hi all:
If i have two tables in an existing database, with a relation one-to-many
(one GROUP to many ITEMs)
table GROUP has columns:
ID (long, primary key)
NAME (string)
table ITEM has columns:
ID (long, primary key)
GROUP_ID (long, foreign key)
NAME (string)
ITEM_COST (double)
I want to design POJO classes "Group" and "Item" that map to these tables
my question is about the "Item" class:
should the "Item" class contain a field "groupId" of type Long, with its
getter and setter, or just a reference to a Group object, or both?
for example:
publie class Item{
..
..
Group group; //this?????
public Group getGroup(){return group;}
publie void setGroup(Group group){this.group = group;}
..
..
Long groupId; //or this??????
public Long getGroupId(){return groupId;}
public void setGroupId(Long groupId){this.groupId = groupId;}
..
..
// or both??????
}
thanks
hilz