Hiya, I've started using Hibernate recently, and think it's great.
I'm using it for maps and sets and whatnot, and don't have any problems with that. I have also used the special one-to-one relationship, where it is appropriate. However, there is something that I am trying to do that seems like it is totally trivial, but I can't figure out how to do it.
I have a class that looks something like this:
class Thing
{
public Widget getPrimaryWidget() {}
public void setPrimaryWidget(Widget widget) {}
public Map getWidgets()
public void setWidgets(Map widgets)
....
}
The problem I am having is with the primaryWidget field. I cannot figure out how to map it in the config file properly.
A one-to-one relationship is not appropriate, since the primary widget guy can change, and won't have the same primary key as the Thing guy.
In the database I have a field that represents the primaryWidgetId, but for the moment I have to use it only as an id, and then load up the object seperately.
How can I do this? Can I just use a property element and set the type to the other mapped type, or...?
Thanks,
Hunter
|