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: HIbernate Filters + User Defined Types
PostPosted: Thu Sep 04, 2008 10:02 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 7:29 am
Posts: 36
Hi All,

I am trying to use Hibernate Filters and apply filtering on User defined Types. It seems Hibernate Filters are unable to map to columns having user defined types.

Also, I am not sure if in the filter-def configuration the type used should be String or the EnumType

All the details are given below.

Can anybody please help!!!

Regards,
Shardul.

Hibernate version:

Code:
Hibernate 3


Mapping documents:

Excerpt of Mapping Doc

User Defined Type

Code:
<typedef name="courseLengthUnitType"
      class="module.commons.dao.tool.EnumUserType">
      <param name="enumClassName">
         module.xxxx.model.type.LengthUnitType
      </param>
   </typedef>

<class>
<property name="lengthUnit" type="courseLengthUnitType">
            <column name="length_unit" length="32" not-null="false"/>
      </property>

<filter name="courseYearLengthUnitFilter" condition="lengthUnit IN (:courseYearLengthUnit)"></filter>

</class>

<filter-def name="courseYearLengthUnitFilter">
      <filter-param name="courseYearLengthUnit" type="java.lang.String"></filter-param>
   </filter-def>



Full stack trace of any exception that occurs:

Code:
19:01:38,866 ERROR [JDBCExceptionReporter] Unknown column 'this_.lengthUnit' in 'where clause'


Name and version of the database you are using:

Code:
MySQL 5.0


The generated SQL (show_sql=true):

Code:
Hibernate: select this_.id as y0_ from core_course this_ where length IN (?) and this_.lengthUnit IN (?) and this_.degreeType IN (?)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2008 2:23 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Filter definitions should use raw SQL in the condition, not HQL. In you example it should be something like:

Code:
<filter name="courseYearLengthUnitFilter" condition="length_unit IN (:courseYearLengthUnit)"


I guess this also means that parameter types are limited to the Java equivalent of the simple SQL column types.


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.