Hi all...

I'm having a little problem trying to map my objects. My mapping looks like this:

<class name="Foo" table="Foo" discriminator-value="0">
<id="fooId" />
<property name="name" />
<subclass name="FooBar" discriminator-value="1">
<one-to-one name="proxy" class="FooBarProxy" constrained="false" cascade="all" />
</subclass>
<subclass name="FooBaz" discriminator-value="2">
<one-to-many name="proxy" class="FooBazProxy" constrained="false" cascade="all" />
</subclass>
</class>


<class name="FooBarProxy" table="FooBar">
 <id="fooBarId" />
 <property name="bar" />
 <set role="baz" table="Baz" lazy="true" cascade="all">
   <key column="fooBarId" />
   <one-to-many class="FooBaz" />
 </set>
</class>

<class name="FooBazProxy" table="FooBaz">
 <id="fooBazId" />
 <property name="baz" />
</class>


The db looks like this:


create table Foo ( fooId bigint not null primary key, discriminator bigint not null, name varchar(256) )
create table FooBar (fooBarId bigint not null primary key, name varchar(256) )
create table FooBaz (fooBazId bigint not null primary key, name varchar(256), fooBarId bigint )



This is what I'm trying to do:


FooBar fb = new FooBar();
Set set = new HashSet();
set.add(new FooBaz());
fb.setBaz(set);
session.save(fb);

FooBar and FooBaz are both subclasses of Foo.


Here's the error log:


Hibernate: insert into Foo ( name, fooId, discriminator ) values ( ?, ?, 1 )
Hibernate: insert into FooBar ( bar, fooBarId ) values ( ?, ? )
Hibernate: insert into Foo ( name, fooId, discriminator ) values ( ?, ?, 2 )
Hibernate: insert into FooBaz ( baz, fooBazId ) values ( ?, ? )
Hibernate: update Foo set fooBarId = ? where fooId = ?
Sep 5, 2002 2:10:56 AM cirrus.hibernate.helpers.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 904, SQLState: 42000
Sep 5, 2002 2:10:56 AM cirrus.hibernate.helpers.JDBCExceptionReporter logExceptions
SEVERE: ORA-00904: "FOOBARID": invalid identifier



I understand why Hibernate tries to set fooBarId in table Foo instead of table FooBaz. What I want to know is if there is another way I can define the mapping and/or the classes to achieve what I want to do. I guess I could use a many-to-many association instead, but I'd really rather not introduce another table if it's at all avoidable.


Does anyone have any suggestions?

Thanks,
-Mark




------------------------------------------------------- This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE! https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel



Reply via email to