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: Association Table With Extra Attributes on Association Table
PostPosted: Tue Sep 19, 2006 11:16 am 
Beginner
Beginner

Joined: Tue Sep 13, 2005 4:54 pm
Posts: 34
Hibernate version: 3.1
Mapping documents: included

I have two tables with a M:M relationship that are joined by an association table. That's easy with Hibernate but now I have two attributes on the association table.
How do I map this?

This is the table structure. Composite primary key on association table.

Image

This is the first class/mapping file: ReportList

Image

This is the second class/mapping file: ReportCriteria

Image


Several questions:

i.) From which object do I access the CRITERIA_ORDER and CRITERIA_STATE attributes?

ii.) Do I need a class for the association table?

iii.) If I need a class for the association, does that need a mapping file?

I have pored over sections 8.2 of the Hibernate Reference 3.1.1 but I can't get it to work. Please don't just vaguely point me there. Please write down the mapping file or the parts of the ones I have that are lacking.

Thank you!!!!!
Ty


Top
 Profile  
 
 Post subject: Solved! Complete Solution To This Problem!
PostPosted: Wed Sep 20, 2006 10:09 am 
Beginner
Beginner

Joined: Tue Sep 13, 2005 4:54 pm
Posts: 34
With the gracious help of Mr. Tenwit, I have arrived at a solution to this problem.

In short, here's what I was trying to do: Two tables joined by an association table. Because there were extra attributes on the association table (beyond the two foreign keys), I had to be able to access the extra attribute on the association table.

So I had:

Person 1:M Attendee M:1 Event


Person.java

Image

Person.hbm.xml

Image


Event.java

Image

Event.hbm.xml

Image


Attendees.java

Image

Attendees.hbm.xml [The mapping in here is most critical, although the others have to be setup correctly too, obviously.]

Image


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.