-->
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: Legacy Mapping simple Linked List
PostPosted: Fri Jun 04, 2010 5:40 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
I want to use Hibernate for a legacy database model.
In this model, lists are implemented with nextID, where an element points to its next element in the list or null, if it is the last element.

Legacy Tables:
GroupTab id, name,...
ElementTab id,groupID, nextID, ...

My first idea was to use a Set and maintain the nextID manually.
Code:
Group.hbm.xml snippedt
  <set name="elements" inverse="true">
     <key column="groupID" />
     <one-to-many class="Element"/>
  </set>

Code:
Element.hbm.xml snippet
      <many-to-one name="group" class="Group" column="groupID"/>
      <many-to-one name="next" class="Element" column="nextID"/>


This does in principle what I want, and the schema export gives me the correct DDL output.

But I feel, that is there is probably a better way to implement this.

The mapping element <list> allows me to use a list_index.
Can I use the list_index in a different way for my situation?

Is there a possibility in Hibernate which takes care of the nextID handling automatically?

Any hint, suggestion would be appreciated.
Thanks


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.