-->
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.  [ 5 posts ] 
Author Message
 Post subject: <any> & <many-to-any>
PostPosted: Fri Oct 07, 2005 12:03 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
I've a situtaion that I think varrants the use of the <any> & <many-to-any>, but I can't find any documentation about them.
Any idea where I can find some information about it?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 3:43 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
The <many-to-any> and <index-many-to-any> elements provide for true heterogeneous associations. These mapping elements work in the same way as the <any> element - and should also be used rarely, if ever.

The above is the sum of the documentation I was able to find on the subject.
The problem that I'm having right now is figuring this out:

Code:
<set
          name='Rules'>
         <key
             column='RuleId' />
         <many-to-any
             id-type='int32'
             meta-type='int32'>
            <column
                name='what is this?' />
         </many-to-any>
      </set>


What is the column element used for?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 4:31 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I think there should be at least two columns, one is the "class" column, and the other one is the "id" column.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 6:39 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Here is the mapping I've here:

Code:
<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.0">
  <class name="Model.Board, Model" table="Boards"    >
    <id name="Id" access="nosetter.camelcase-underscore" column="BoardId" type="Int32"  unsaved-value="0">
      <generator class="native">
      </generator>
    </id>
    <property name="_locationUnitId" access="field" column="LocationId" type="Int32"        />
    <property name="_createdById" access="field" column="CreatedBy" type="Int32"        />
    <property name="Name" access="property" column="BoardName" type="System.String"        />
    <property name="Description" access="property" column="BoardDescription" type="System.String"        />
    <property name="StartDate" access="property" column="BoardStartDate" type="System.DateTime"        />
    <property name="EndDate" access="property" column="BoardEndDate" type="System.DateTime"        />
    <property name="DateCreated" access="property" column="DateCreated" type="System.DateTime"        />
    <property name="Status" access="property" column="BoardStatus" type="Byte"        />
    <property name="BaseAssignmentLocked" access="nosetter.camelcase-underscore" column="BaseAssignmentLocked" type="Boolean"        />
    <many-to-one name="BoardTemplate" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" class="Model.BoardTemplate, Model" column="BoardTemplateId"      />
    <set name="Shifts" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" table="Shifts"   inverse="true"    >
      <key column="BoardID" />
      <one-to-many class="Model.Shift, Model" />
    </set>
    <set name="Rules" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" table="Rules"   inverse="true" cascade="all"   >
      <key column="RuleEntityId" />
      <many-to-any id-type="Int32" >
        <column name="ShouldBeClass" />
        <column name="ShouldBeId" />
      </many-to-any>
    </set>
  </class>
</hibernate-mapping>


The SQL that NHibernate generates looks like this:

Code:
SELECT rules0_.RuleEntityId as RuleEnt10___, rules0_.ShouldBeClass as RuleEnti9___, rules0_.ShouldBeId as ShouldBeId__ FROM Rules rules0_ WHERE rules0_.RuleEntityId=@p0


What I /wants/ it to do is to select by the class as well, so it would loads only the rules that relates to a board.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 7:21 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Wait a second, what exactly does a <many-to-any> does anyway?
I assumed it is the other side of an <any> link.

The situation I've is a board with rules. What a rule (table per hierchy) can be applied to several objects.
Does it give me this?


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