-->
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.  [ 2 posts ] 
Author Message
 Post subject: Subclass Discriminator and Bind Variables Problem
PostPosted: Wed Jan 23, 2008 1:47 pm 
Regular
Regular

Joined: Tue Oct 07, 2003 10:20 am
Posts: 77
Hibernate version: 3.2.5GA

Database: Oracle 10g / DB2 v8

Mapping documents:

Code:
<hibernate-mapping>
    <class name="com.qxlva.Person" table="PERSON" dynamic-update="true" dynamic-insert="true" lazy="true">
        <id name="pid" column="PERSON_PID" type="long" unsaved-value="null">
            <generator class="seqhilo" />
        </id>
        <discriminator column="PERSON_TYPE" length="50" type="string"/>
        <property name="familyName" column="FAMILY_NAME" type="string"/>
        <subclass name="com.qxlva.PersonOne" discriminator-value="PERSON_ONE" />
        <subclass name="com.qxlva.PersonTwo" discriminator-value="PERSON_TWO" />
    </class>
</hibernate-mapping>


I've attempted to look for anyone else that's hit this problem, but have hit a blank.

Our application makes heavy use of mappings with subclasses identified with discriminators. We're finding that due to the way the SQL queries are generated by Hibernate, it's leading to a lot of hard parses of the queries in the database, which is subsequently impacting on performance.

For example, the above mapping would generate the following SQL, when loading by identifier, using the following code:

Code:
session.load(PersonOne.class, identifier);

Quote:
select personone0_.PERSON_PID as PERSON1_1_0_, personone0_.FAMILY_NAME as FAMILY3_1_0_ from PERSON personone0_ where personone0_.PERSON_PID=? and personone0_.PERSON_TYPE='PERSON_ONE'

The majority of our hard parses are being caused by the discriminator section of the query having a hard-coded where-clause value, so my simple question is this: is there any way to configure Hibernate to use bind variables for setting the discriminator value? I'm aware that we can set the discriminator values via bind variable for HQL queries, so these don't concern me. The queries which do concern me are those which retrieve via identifier, usually when pulling out lazy-loaded associations, as I don't have direct control over them (or at least I don't think I do!).

I've spent most of the day immersed in the Hibernate source code and my guess is that there isn't a way to configure this, but before I start on the lengthy task of potentially adding this functionality in, I thought it would be better to check.
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 11:12 am 
Newbie

Joined: Sat Jun 14, 2008 5:45 am
Posts: 3
We encounter the same parsing problem with discriminator columns...
Have you found a workaround ?


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