Hello,
I am trying to figure out the best way to implement the structure I have in mind.
I have a
Party entity which can have multiple
Locations. Each
Location can belong to multiple
Parties. Therefore, I need a
PartyLocation table to express the relations.
So far so good. The problem is that I want to mark a particular Location as the
primary Location for a given
Party.
From a sql minded perspective I would just add a flag column to the
PartyLocation table.
But I don't quite know how to express this in Java/Hibernate. Do I add a property to the
Party class (primaryLocation)? Or to the Location class?
Or do I need to actually create a PartyLocation class? This is what I'd like to avoid so I don't have to write
Code:
party.getPartyLocation().getLocation().getCity().
FYI I am using the SchemaExport tool to create the schema and I'd like to be able to continue using it...
Thanks in advance!
Bobby
Hibernate version: 2
Name and version of the database you are using:MySQL
SQLCode:
create table Party (
PartyId bigint not null,
{...}
)
create table Location (
LocationId big int not null,
{...}
)
create table PartyLocation(
PartyId bigint not null,
LocationId bigint not null
)