| To: | users@xxxxxxxxxx |
|---|---|
| Subject: | Hibernate inheritence and collections |
| From: | <twcrone@xxxxxxxxxxxxx> |
| Date: | Tue, 07 Nov 2006 15:57:26 -0500 |
| Delivered-to: | mailing list users@cinjug.org |
| In-reply-to: | <f9fb862b185d2.45507d0b@insightbb.com> |
| Mailing-list: | contact users-help@cinjug.org; run by ezmlm |
| Priority: | normal |
| References: | <f73bb58e1e300.454f67c2@insightbb.com> <DC1C7328E353C14589E9613E46F919F1EDE9C7@s000pex03.HaverstickConsulting.com> <4550B4B3.4060104@digilore.com> <eb4296c40611070831r5396e05meb4d1c666eb2e682@mail.gmail.com> <f9fb862b185d2.45507d0b@insightbb.com> |
|
I am current mapping tables from an semi-existing data model to a class hierarchy. There is a super class (Contact) in a table that has two subclasses mapped as <joined-subclass> elements (Phone and Address). The super class has FKs to a class that has collections of both subclass types (Party). Saving collections of both types is no big deal but then fetching the two distinct collections is difficult because the FK column is in the super class table. If I specify the <one-to-many class...> as the subclass then it complains that the FK is not in the subclasses table. If I specify the <one-to-many class...> as the super class then it fetches only the subclass items that were specified first in the mapping. Atempt #1 <bag name="addresses" inverse="true" cascade="all" lazy="false"> <key column="partyId" not-null="true"/> <one-to-many class="pkg.Address"/> </bag> <bag name="phones" inverse="true" cascade="all" lazy="false"> <key column="partyId" not-null="true"/> <one-to-many class="pkg.Phone"/> </bag> *** partyId not in subclass table Atempt#2 <bag name="addresses" inverse="true" cascade="all" lazy="false"> <key column="partyId" not-null="true"/> <one-to-many class="pkg.Contact"/> </bag> <bag name="phones" inverse="true" cascade="all" lazy="false"> <key column="partyId" not-null="true"/> <one-to-many class="pkg.Contact"/> </bag> *** load of Party (that has addresses and phones) object results in a List of only Address objects in addresses and phones. Any ideas? . - Todd |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [cinjug-users] Hibernate mapping extra data in link tables, twcrone |
|---|---|
| Next by Date: | :SPAM: Oh Man, My Sperm is Great, Magdalena Frazier |
| Previous by Thread: | Re: [cinjug-users] Hibernate mapping extra data in link tables, twcrone |
| Next by Thread: | :SPAM: Oh Man, My Sperm is Great, Magdalena Frazier |
| Indexes: | [Date] [Thread] [Top] [All Lists] |