-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Best way to implement a label table?
PostPosted: Tue Mar 11, 2008 4:30 am 
Regular
Regular

Joined: Mon Mar 10, 2008 6:40 pm
Posts: 114
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.