-->
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: WHERE clause in SET mapping inside a COMPONENT
PostPosted: Fri May 18, 2007 5:59 pm 
Newbie

Joined: Wed May 16, 2007 1:35 pm
Posts: 4
I am trying to add to my class (class A) a component (class B) that has a one-to-many mapping to a third class (class C) for several properties of class A.

Code:
    <component name="b1" lazy="true" class="com.xyz.B">
      <set cascade="all-delete-orphan" [b]where="entity_type='b1'"[/b] lazy="false" name="localizedStrings">
        <key column="entity_id"/>
        <one-to-many class="com.xyz.C"/>
      </set>
    </component>

    <component name="b2" lazy="true" class="com.xyz.B">
      <set cascade="all-delete-orphan" [b]where="entity_type='b2'"[/b] lazy="false" name="localizedStrings">
        <key column="entity_id"/>
        <one-to-many class="com.xyz.C"/>
      </set>
    </component>


We use XDoclet to generate the mappings. The where="entity_type='b1'" in bold were added manually.

I have a class A which has multiple properties of class B. Class B in turn has a one-to-many mapping to class C.

Code:
class A { 
  ...
  public B b1;
  public B b2;
  ...
}


As I mentioned above, we added the where="entity_type=..." condition to differentiate between instances of C that belong to different properties of A, in this case b1 and b2.

The problem is that when I load an instance of class A, both b1 and b2 are initialized with the same instances of C, which means my where clauses are being ignored.

Is there any way to do this?


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.