Joined: Thu Jan 13, 2005 6:24 pm Posts: 12
|
I've looked at the forumns and Hibernate-in-action book but I seem to not be able to figure out how to do something that seems should be simple. I have a simple table that maps persons to groups..
person_to_group
fk person_id references persons
fk group_id references groups
groups
pk id
name
persons
pk id
name
Now it seems to me that I should be able to do something like...
person_to_group=new PersonToGroup();
person_to_group.setPersonId=(5);
person_to_group.setGroupId=(6);
However the PersonToGroup is mapped with a many-to-one associations to
person and group, so all I have is setters and accessor that take/return Person or Group objects. This is good when I'm navigating the oject graph... but when I just one to insert a relationship into the database I would now have to fetch the Person and Group object by identifier and then set them on the PersonToGroup object. These two extra database SELECTS are completely unecessary since I already know the identifiers and I don't need any additional data in order to persist the PersonToGroup object. Can anyone give me some pointers on this issue?
|
|