-->
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: Mapping an association without FK
PostPosted: Fri Apr 07, 2006 3:58 pm 
Newbie

Joined: Thu Dec 01, 2005 11:34 am
Posts: 19
Hibernate version:
3.1.2

I have a mapping question that I'm not exactly sure how to handle, or even where in the documents would be the best place to read.

I have two Entities.

Entity FOO has a field called "Position" which is a number, and represents some position in space.

Entity BAR has two fields called "startPosition" and "endPosition" where are numbers, and represent the start and end coordinates of their position in space.

I'd like to have a relationship between the two entities, so if they overlap the same spot in space, they'd be related. You could imagine the relationship as a many to many, where any number of FOOs could overlap a BAR, or vice-versa.

In SQL, I'd solve this with a 'between' query:

Select Foo.*, Bar.*
from Foo, Bar
where Foo.position between Bar.startPosition and Bar.endPosition

Should this sort of thing be mapped, so that I could call Bar.getFooSet(), or Foo.getBarSet()?

Or should map the two entities without an association, query them with HQL, and then manually associate them?

I've been looking at the documentation, and the closest I can guess is the end of section 7.6 "more complex association mapping", and using a subselect with the SQL above (or that addresses the PKs of each field)

Any feedback would be appreciated.


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.