-->
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.  [ 4 posts ] 
Author Message
 Post subject: Complex Many to Many Relationship Mapping?
PostPosted: Thu Jun 07, 2007 7:23 pm 
Beginner
Beginner

Joined: Fri Jun 01, 2007 4:55 pm
Posts: 24
Hibernate version: 1.2.0

I am wondering if someone would be kinda enough to perhaps provide a suitable mapping for this structure of classes.

I have a class Webiste That has properties and a collection of Website Tests. This is a many to many relationship (therefore the database has an association table. Fairly straight forward so far - now in that association table I am storing other information - such as the date a test was added to a website, whether the test is enabled. So that association table has some other data too, other than just linking the two tables.

I guess what i want to achieve is to have my Website object, have a property of tests (which is a strongly typed collection) and in the collection have Website Test objects which contains information about the test and information relating to that test linked with the website (such as date)

Shout if that doesn't make any sense (vb syntax preferred, but wont turn down any help!)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 10, 2007 4:56 am 
Beginner
Beginner

Joined: Fri Jun 01, 2007 4:55 pm
Posts: 24
Here is a table structure; might help with what i mean:

Code:
[b]Websites[/b]
WebsiteID    Name
1            hotmail.com
2            builtonrock.co.uk



[b]Tests[/b]
TestID         Description
6              PING
9              Render



[b]WebsiteTestSettings[/b]
WebsiteID         TestID          Frequency       Status
1                 6               60              1
1                 9               180             1
2                 6               30              0



The website Test settings does your usual Many-to-Many relationship handling, but it also has some extra values.

I not even sure where to start mapping something like that.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 10, 2007 1:16 pm 
Regular
Regular

Joined: Wed Apr 25, 2007 4:18 am
Posts: 51
Location: Belarus, Gomel
Hi oblivionsy!

You'd better create 3 classes and use simple many-to-one and one-to-many associations.

_________________
WBR, Igor


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 10, 2007 6:53 pm 
Beginner
Beginner

Joined: Fri Jun 01, 2007 4:55 pm
Posts: 24
I considered that, but ruled it out cos a website doesnt just have website test Settings, it also has the test information too. I need to be able to merge those two together somehow. Also, the relationships are not necessarily directly reversible. A website would have a collection of tests + their settings. But a test would only have a collection of websites (so those extra fields could be ignored) - can this still be done like that?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.