-->
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: Multi-Use association table
PostPosted: Wed Jun 23, 2004 4:22 pm 
Newbie

Joined: Wed Jun 23, 2004 9:36 am
Posts: 1
Location: Reston, VA
All,

I have two sorts of relationships being maintained in an association table, and I've been banging my head against trying to figure out how to map them.

What I have is a form type and an application type as below.:

Code:
public class Form{
   private long _id;
   private long _name;
/*Accessors*/
}


Code:
public class Application{
   private long _id;
   private String _name;
   private List _mandatoryForms;
   private List _optionalForms;
/*Accessors*/
}


An application can have any number of optional forms or mandatory forms. The relationship between objects of these two types is maintained in a single table (TPACKAGES) with the following columns:
  1. pid - A primary key
  2. application_id - The primary key for the application
  3. form_id - The primary key for the form
  4. ordernum - The order the form should appear in the List
  5. required - 1 if the form should be mandatory 0 if it should be optional

Testing with just a single list of forms (ignoring the required column) it all worked with this mapping:

Code:
<hibernate-mapping package="eg">
   <class name="Application" table="tapplication">
      <id name="id" column="appid" type="long">
         <generator class="sequence">
            <param name="sequence">APPIDSEQ</param>
         </generator>
      </id>
      <property name="name" column="appname" type="string"/>
      <list name="MandatoryForms" lazy="false" table="tpackages">
         <key column="application_id"/>
         <index column="ordernum"/>
         <many-to-many class="Form" column="form_id"/>
      </list>
   </class>
</hibernate-mapping>


So, my question: Is there any way to modify the list mapping to include the specification of a value for the required column? I know I can use the "where" attribute to retrieve configured objects, but is there any way I can ensure that the requried attribute is correctly specified for .save'd application objects?

Thanks much,
- Court


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.