-->
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: Discriminator formula wrapping value in quotes twice.
PostPosted: Thu Jan 11, 2007 7:41 pm 
Newbie

Joined: Sun Nov 05, 2006 3:39 pm
Posts: 1
Hibernate version:
hibernate3 3.2.1
hibernate-annotations 3.2.1

Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="domain">
    <class name="SystemListItem" table="system_list_item" discriminator-value="null">
        <id name="id" column="system_item_id" type="int" unsaved-value="-1">
            <generator class="sequence">
                <param name="sequence">system_item_id</param>
            </generator>
        </id>
        <discriminator formula="(select sl.system_list_name from system_list sl where sl.system_list_id = system_list_system_list_id)" type="java.lang.String"/>
        <property name="code" column="system_item_code" type="java.lang.String" length="10"/>
        <property name="name" column="system_item_name" type="java.lang.String" length="100"/>
        <property name="createDate" column="create_date" type="java.util.Date"/>
        <property name="modifyDate" column="modify_date" type="java.util.Date"/>
        <subclass name="Role" discriminator-value="User Roles"/>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
Criteria criteria = session.createCriteria(SystemListItem.class);
criteria.add(Restrictions.eq("class", Role.class));


Name and version of the database you are using:
PostgreSQL 8.1

Debug level Hibernate log excerpt:
Code:
"2007-01-11 17:17:16,416 DEBUG [org.hibernate.SQL]
    select
        this_.system_item_id as system1_0_0_,
        this_.create_date as create2_0_0_,
        this_.modify_date as modify3_0_0_,
        this_.system_item_code as system4_0_0_,
        this_.system_item_name as system5_0_0_,
        (select
            sl.system_list_name
        from
            system_list sl
        where
            sl.system_list_id = this_.system_list_system_list_id) as clazz_0_
    from
        system_list_item this_
    where
        (
            1=1
        )
        and (
            select
                sl.system_list_name
            from
                system_list sl
            where
                sl.system_list_id = this_.system_list_system_list_id
        )=?
"2007-01-11 17:17:16,427 TRACE [org.hibernate.type.StringType] binding ''User Roles'' to parameter: 1


I have several class that inherit from a common SystemListItem base class. One of which is named Role. These classes are stored in a single table using a formula to determine the descriminator value from a parent table that just adds names to each (legacy db). My problem is that the discriminatorSQLValue gets setup wrapped with single quotes and gets rewrapped when used in the where clause of a query to select only certain subclasses. This is similar to the last post in the JIRA issue below but it is marked as resolved as of about a year ago.

http://opensource.atlassian.com/project ... se/HHH-746

I will probably end up ditching the formula and just using the IDs from the parent table but this way makes the mapping files easier to read. Are there any other workarounds for this issue?

Thanks.


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.