-->
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: many-to-one relationship returns wrong polymorphic type
PostPosted: Tue Mar 15, 2005 3:55 pm 
Newbie

Joined: Tue Mar 15, 2005 3:48 pm
Posts: 1
Location: Switzerland
Hello everybody

during my work with Hibernate 3.0rc1 I discovered the following bug:

when I resolve the many-to-one relationship from a Privilege-Instance to it associated Resource instance, I always get an Instance of type "Resource" whereas a type derived from "Resource" is expected.
I tested the same mapping documents with hibernate 2.1.8 and I get back an object of the correct subclass. Did anybody else experience the same problem with hibernate3? I did not find a bug report for this so far, so could anybody please confirm this behaviour such that I maybe could open a bug report?

Thanks in advance
Dan

Hibernate version:3.0rc1

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
<class
name="ch.hasware.pmp.server.dom.Privilege"
table="PMP_PRIVILEGE"
>

<id
name="id"
column="OBJECT_ID"
type="java.lang.Long"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Privilege.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="action"
type="java.lang.String"
column="ACTION"
/>

<many-to-one
name="resource"
class="ch.hasware.pmp.server.dom.Resource"
cascade="none"
outer-join="auto"
column="RESOURCE_ID"
/>

<set
name="roles"
table="PMP_ROLE_TO_PRIVILEGE"
lazy="false"
cascade="none"
sort="unsorted"
>

<key
column="PRIVILEGE_ID"
>
</key>

<many-to-many
class="ch.hasware.pmp.server.dom.Role"
column="ROLE_ID"
outer-join="auto"
/>

</set>

<set
name="users"
table="PMP_USER_TO_PRIVILEGE"
lazy="false"
cascade="none"
sort="unsorted"
>

<key
column="PRIVILEGE_ID"
>
</key>

<many-to-many
class="ch.hasware.pmp.server.dom.User"
column="USER_ID"
outer-join="auto"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Privilege.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
<class
name="ch.hasware.pmp.server.dom.Resource"
table="PMP_RESOURCE"
>

<id
name="id"
column="OBJECT_ID"
type="java.lang.Long"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Resource.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<discriminator
column="TYPE"
/>

<property
name="name"
type="java.lang.String"
column="NAME"
length="64"
/>

<set
name="privileges"
lazy="false"
cascade="all-delete-orphan"
sort="unsorted"
order-by="ACTION"
>

<key
column="RESOURCE_ID"
>
</key>

<one-to-many
class="ch.hasware.pmp.server.dom.Privilege"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Resource.xml
containing the additional properties and place it in your merge dir.
-->
<subclass
name="ch.hasware.pmp.server.dom.UserPool"
discriminator-value="TYPE_USERPOOL"
>

<set
name="users"
lazy="false"
cascade="all-delete-orphan"
sort="unsorted"
order-by="NAME"
>

<key
column="POOL_ID"
>
</key>

<one-to-many
class="ch.hasware.pmp.server.dom.User"
/>

</set>

<set
name="roles"
table="PMP_USERPOOL_TO_ROLE"
lazy="false"
cascade="none"
sort="unsorted"
>

<key
column="USERPOOL_ID"
>
</key>

<many-to-many
class="ch.hasware.pmp.server.dom.Role"
column="ROLE_ID"
outer-join="auto"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-UserPool.xml
containing the additional properties and place it in your merge dir.
-->

</subclass>
<subclass
name="ch.hasware.pmp.server.dom.Folder"
discriminator-value="TYPE_FOLDER"
>

<set
name="sites"
lazy="false"
cascade="all-delete-orphan"
sort="unsorted"
order-by="NAME"
>

<key
column="FOLDER_ID"
>
</key>

<one-to-many
class="ch.hasware.pmp.server.dom.Website"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Folder.xml
containing the additional properties and place it in your merge dir.
-->

</subclass>
<subclass
name="ch.hasware.pmp.server.dom.Website"
discriminator-value="TYPE_WEBSITE"
>
<property
name="location"
type="java.lang.String"
column="LOCATION"
/>

<set
name="realms"
lazy="false"
cascade="all-delete-orphan"
sort="unsorted"
order-by="NAME"
>

<key
column="WEBSITE_ID"
>
</key>

<one-to-many
class="ch.hasware.pmp.server.dom.Realm"
/>

</set>

<set
name="roles"
lazy="false"
cascade="all-delete-orphan"
sort="unsorted"
order-by="NAME"
>

<key
column="WEBSITE_ID"
>
</key>

<one-to-many
class="ch.hasware.pmp.server.dom.Role"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Website.xml
containing the additional properties and place it in your merge dir.
-->

</subclass>
<subclass
name="ch.hasware.pmp.server.dom.Realm"
discriminator-value="TYPE_REALM"
>
<property
name="path"
type="java.lang.String"
column="PATH"
/>

<property
name="authTypes"
type="int"
column="AUTH_TYPES"
/>

<many-to-one
name="website"
class="ch.hasware.pmp.server.dom.Website"
cascade="none"
outer-join="auto"
column="WEBSITE_ID"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Realm.xml
containing the additional properties and place it in your merge dir.
-->

</subclass>

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:MySQL 4.1 / Oracle 9.2

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


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.