-->
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: where attribute question
PostPosted: Thu Jun 03, 2004 9:30 am 
Newbie

Joined: Tue May 11, 2004 11:32 am
Posts: 16
I have a collection mapping like this:

Code:
<hibernate-mapping>
  <class name="my.FooImpl" table="foo_table">
    <id name="mId" column="id" type="long" access="field">
      <generator class="sequence">
        <param name="sequence">foo_seq</param>
      </generator>
    </id>
    <set name="bars" table="my_link_table" access="field" lazy="true">
      <key column="child_id"/>
      <many-to-many column="parent_id" class="my.FooImpl"/>
    </set>
  </class>

  <class name="my.BarImpl" table="bar_table">
    <id name="mId" column="id" type="long" access="field">
      <generator class="sequence">
        <param name="sequence">foo_seq</param>
      </generator>
    </id>
    <property name="type" column="type" type="string"
  </class>   
</hibernate-mapping>


I'm having trouble with the "where" attribute of FooImpl.bars. How do I limit the contents of the set to only those isntances of BarImpl that have a specific value for "type"?

I was thinking of something like this:
Code:
  where="my.BarImpl.type='something'"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 9:32 am 
Newbie

Joined: Tue May 11, 2004 11:32 am
Posts: 16
Of course, as soon as I post, I noticed my mapping is wrong. The class of the set should be BarImpl:

Code:
<hibernate-mapping>
  <class name="my.FooImpl" table="foo_table">
    <id name="mId" column="id" type="long" access="field">
      <generator class="sequence">
        <param name="sequence">foo_seq</param>
      </generator>
    </id>
    <set name="bars" table="my_link_table" access="field" lazy="true">
      <key column="foo_id"/>
      <many-to-many column="bar_id" class="my.BarImpl"/>
    </set>
  </class>

  <class name="my.BarImpl" table="bar_table">
    <id name="mId" column="id" type="long" access="field">
      <generator class="sequence">
        <param name="sequence">foo_seq</param>
      </generator>
    </id>
    <property name="type" column="type" type="string"
  </class>   
</hibernate-mapping>


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.