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.
|