-->
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: Attributes in Join Tables
PostPosted: Fri Feb 11, 2005 10:47 am 
Newbie

Joined: Fri Feb 11, 2005 10:23 am
Posts: 4
Location: Developer
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

SQL
Code:
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
)


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.