-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate3 and table-per-subclass discriminator
PostPosted: Sun Dec 19, 2004 11:14 pm 
Regular
Regular

Joined: Fri Mar 26, 2004 11:45 am
Posts: 75
On http://www.hibernate.org/200.html it says the following:

"mixed" table-per-hierarchy / table-per-subclass inheritance mapping strategy, and table-per-subclass inheritance with a discriminator column

There is also a note indicating that this functionality is already implemented in Hibernate3. However, the DTD does not allow discriminator-value to be used with joined-subclass element.

How do I use table-per-subclass strategy with discriminator-value?
Thanks.

Alec


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 19, 2004 11:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
http://blog.hibernate.org/cgi-bin/blosx ... 08/25#join


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 20, 2004 12:13 am 
Regular
Regular

Joined: Fri Mar 26, 2004 11:45 am
Posts: 75
hmm, I tried the last example on that link and I got this error:
aused by: org.xml.sax.SAXParseException: Attribute "outer-join" must be declared for element type "join".

I am using this DTD:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

Am I using the right DTD or the DTD is inconsistent?
Thanks.

Alec


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 20, 2004 12:27 am 
Regular
Regular

Joined: Fri Mar 26, 2004 11:45 am
Posts: 75
Gavin, one more question.

Consider the following scenario, which I copied from the link that you just sent me:
<class name="Foo" table="foos" discriminator-value="0">
<id name="id">...</id>
<discriminator column="type" type="int"/>
<property name="name"/>
<subclass name="Bar" discriminator-value="1">
<join table="bars" outer-join="false">
<key column="fooId"/>
<property name="amount"/>
</join>
</subclass>
</class>


When a new Bar object is persisted in the database it forces a new row to be inserted in the foo table. Can I disable this?

The reason for disabling this is that in my case the "bar" table INHERITs from the "foo" table (SQL 99 feature), so when I insert a row in the "bar" table it automatically creates a corresponding row in the "foo" table. Therefore, I don't want Hibernate to explicitly insert a row in table "foo".

Thanks.
Alec


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 20, 2004 1:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, not possible.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 20, 2004 6:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
FYI, the outer-join attribute is replaced by the fetch attribute in this release.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 20, 2004 7:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually, it is possible, just write a custom EntityPersister. (It might help to work off the HB3 codebase for this.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.