-->
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: ternary association
PostPosted: Sat Apr 29, 2006 1:04 am 
Newbie

Joined: Thu Apr 27, 2006 4:13 am
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: hibernate 1.0.2.0

Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="myWindowsApplication.Project,myWindowsApplication" table="project" lazy="true">

<id name="Projectid" column="projectID" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<property column="projectName" type="String" name="ProjectName" length="20" />

<set name="TernarrayList" table="users_workGroup_project">
<key column="projectID"/>
<composite-element class="myWindowsApplication.UGP,myWindowsApplication">
<many-to-one name="User" class="myWindowsApplication.Users,myWindowsApplication" column="userID"/>
<many-to-one name="Group" class="myWindowsApplication.WorkGroup,myWindowsApplication" column="workGroupID"/>
</composite-element>
</set>
</class>
</hibernate-mapping>
/////////////////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="myWindowsApplication.WorkGroup,myWindowsApplication" table="workGroup" lazy="true">

<id name="WorkGroupid" column="workGroupID" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<property column="workGroupName" type="String" name="WorkGroupName" length="20" />

</class>
</hibernate-mapping>
////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="myWindowsApplication.Users,myWindowsApplication" table="users" lazy="true">

<id name="Userid" column="userID" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<property column="firstName" type="String" name="FirstName" length="20" />

</class>
</hibernate-mapping>
////////////////////////////////////////////////////////////////////

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

i have 3 tables "users", "workGroup" and "project"
they join with a joint table named "users_workGroup_project"
and have a ternary association.
please describe following code about "Ternary association"
<set name="TernarrayList" table="users_workGroup_project">
<key column="projectID"/>
<composite-element class="myWindowsApplication.UGP,myWindowsApplication">
<many-to-one name="User" class="myWindowsApplication.Users,myWindowsApplication" column="userID"/>
<many-to-one name="Group" class="myWindowsApplication.WorkGroup,myWindowsApplication" column="workGroupID"/>
</composite-element>
</set>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 29, 2006 2:51 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
i'm not really sure what you're asking but your Project class would have a property called "TernarrayList" that was composed of 0..* classes of type myWindowsApplication.UGP.

accessing them might be somethign like:

foreach (myWindowsApplication.UGP ugp in this.TernarrayList) {
DoSomethingWith(ugp.Group.WorkGroupName);
DoSomethingWith(ugp.User.FirstName);
}


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.