-->
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: Proxy Object with Inheritance
PostPosted: Mon Dec 05, 2005 5:42 pm 
Newbie

Joined: Mon Dec 05, 2005 5:26 pm
Posts: 2
Hibernate version: 3.05

Interesting scenario occuring for me here. I have mapped my inheritence tree the following way:

A root class
B inherits from A
C inherits from B
D inherits from B

Here is my mapping doc (Note: object B is not mapped because it does not have any new functionality than object A):

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="package.A" table="A" discriminator-value="0" >

<cache usage="read-only" />

<id name="number" type="java.lang.Integer" unsaved-value="null">
<column name="COLUMN_1"/>
</id>

<discriminator formula="CASE WHEN VALUE_1 IN (5,17) THEN 1 ELSE CASE WHEN VALUE_1 IN (6,18) THEN 2 ELSE 0 END END" type="string" />

<subclass name="package.C" discriminator-value="1"></subclass>
<subclass name="package.D" discriminator-value="2"></subclass>

</class>

</hibernate-mapping>




99.9% of the time when I request a list of C objects using the code below, I get a list of physical C objects; but 0.1% of the time I get, for example: 3 C objects and 1 C$$EnhancerByCGLIB$$... proxy object. Of course I cannot map the object or reference it as a C object or I get an ClassCastException.

Code:

createQuery("FROM A Type1, A Type2 WHERE Type2.value_2 = Type1.value_2 AND Type2.value_1 IN (5,17) AND Type1.value_3 = ?").setInteger(0, object.getNumber()).list();

Any idea why for 0.1% of the time Hibernate does not map the object directly?

Thanks is advance...


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.