-->
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: Collections containing different types of objects + history
PostPosted: Thu Oct 09, 2003 4:41 am 
Newbie

Joined: Thu Oct 09, 2003 4:30 am
Posts: 7
What we want to do is a bit different from the standard way people use relational databases. The objects we want to store contains a [b]variable[/b] ammount of items in a collection and each item may be [b]one of several[/b] known objects. I already saw something similar on the forum posted by [sfarrel] and [dotski81]

We have

public class ItemContainer {
Long id;
ArrayList items;
...
public Long getId(){...}
public void setId(Long id){...}
public List getItems() {...}
public List setItems() {...}
}

Each item in the items list may now be one of several known classes e.g.

public class ItemTypeA {
Long id;
ItemContainer owner;
...
}

public class ItemTypeB {
Long id;
ItemContainer owner;
...
}

public class ItemTypeC {
Long id;
ItemContainer owner;
...
}

Two questions:

[b]1)[/b] How whould you recommend doing this in Hibernate? I think in the direction of letting ItemTypeA,B,C extends some base class ItemType and then use a normal <list> ...<one-to-many class="ItemType"/></list> mapping in the ItemContainer map.

[b]2)[/b] I also need to track history for every item change. Do I need to save a clone of every changed item in a seperate table or what is the best way to do it.

I just need some ideas. I'm sure someone else did something simmilar.
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.