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: Map collection to a joined-subclass
PostPosted: Wed Mar 04, 2009 5:21 pm 
Newbie

Joined: Wed Mar 04, 2009 3:26 pm
Posts: 4
Ok, here's my problem: I have these classes:

Code:
public class Baz{
    public Int32 Id { get; set; }
...
    public virtual IList<Foo> Foos { get; set; }
    public virtual IList<Bar> Bars { get; set; }
...
}

public class Foo{
    public Int32 Id { get; set; }
...
}

public abstract class AbstractBar{
    public Int32 Id { get; set; }
...
}

public class Bar : AbstractBar{
    ...
}


with these database tables:

Code:
TABLE BAZ(ID,...)
TABLE FOO(ID,BAZ_ID...)
TABLE ABSTRACT_BAR(ID,BAZ_ID...)
TABLE BAR(ABSTRACT_BAR_ID,...)


and these mappings:

Code:
<class name="Baz" table="BAZ">
    <id name="Id" column="ID" type="Int32">...</id>
...
        <bag name="Foos" inverse="true" cascade="all">
            <key column="BAZ_ID" />
            <one-to-many class="Foo" />
        </bag>
        <bag name="Bars" inverse="true" cascade="all">
            <key column="BAZ_ID" />
            <one-to-many class="Bar" />
        </bag>
</class>

<class name="Foo" table="FOO">
    <id name="Id" column="ID" type="Int32">...</id>
...
</class>

<class name="AbstractBar" table="ABSTRACT_BAR">
    <id name="Id" column="ID" type="Int32">...</id>
...
    <joined-subclass name="Bar" table="BAR">
        <key column="ABSTRACT_BAR_ID" />
    </joined-subclass>
...
</class>


When I try to load a Baz, the Foos load perfectly, but not the Bars because the column BAZ_ID doesn't exist in BAR, altough it exists in it's parent ABSTRACT_BAR.

Any ideas on how can I map the list of bars? Thanks!

_________________
Darth Reisender


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.