If I have following 2 tables, what's the best way to model this in hibernate?
Event
Id
Event_Type_Id
Event_Type
Event_Type_Id
Label
I would have an eventType field in my Event class and a many-to-one element in my event.hbm.xml. I would do something like this to create a new event with type "Party":
Code:
EventType party = new EventType();
party.setId(PARTY_ID);
Event partyEvent = new Event();
partyEvent.setEventType(party);
session.save(partyEvent);
Does that seem right to you guys? Is there a more elegant way to handle this?