-->
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.  [ 2 posts ] 
Author Message
 Post subject: Relationship that is ordered and allows duplicates
PostPosted: Mon Mar 12, 2007 11:31 am 
Newbie

Joined: Mon Mar 12, 2007 11:12 am
Posts: 3
Location: Australia
I'm trying to map a collection/List of Stations onto a Route. From Route, the relationship is @OneToMany (or @ManyToMany if stations can be used by more than one route?)

It is crucial that the order of the stations is maintained when users add/remove/shuffle stations after the station list has originally been specified.

eg: if a route is originally specified as "Waterloo, Embankment, Leicester Square, Heathrow, Edgware", users should be able to perform the following operations on the list (my API is simplified for illustrative purposes):
Code:
////////////////////////////////
insert(0, "Kennington");
insert(3, "Charing Cross");
delete("Heathrow");
append("Tottenham Court Road");
append("Goodge Street");
move(LAST,"Edgware");

em.merge(route);
////////////////////////////////


I think I'll need to use a join table, but what's the best way to get Hibernate (JPA) to ensure that the station PKs are stored/fetched in the correct order?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 13, 2007 10:57 am 
Newbie

Joined: Mon Mar 12, 2007 11:12 am
Posts: 3
Location: Australia
For the sake of anyone else who is seeking a solution to a similar problem, I've solved my problem using @IndexColumn.


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

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.