I've got a mapped class in Hibernate that contains a named sql-query that calculates the minimum of an integer for some search-parameters. The actual query is quite complex (so I can neither write it as a Criteria nor as an HQL in my Hibernate-version).
The return type in the database is an integer but I've got an Usertype that maps that integer to a date (db-schema modification is also not possible in my case).
The question is: how to specify a return type for my named query that is resolved via a Custom-UserType.
I tried the following. My UserType is
<hibernate-mapping>
<typedef class="com.package.MyUserType" name="MyUserType"/>
<class>...</class>
<sql-query name="queryName">
<return-scalar column="alpha" type="MyUserType"/>
select min(myColumn) as alpha from Table01 where attribute=:param
</sql-query>
</hibernate-mapping>
But executing that named query results in
org.hibernate.MappingException: could not determine type null
But MyUserType
is working fine inside my class-mapping.
edit:
I just found out that it is working fine if I use com.package.MyUserType
as type. So the problem seems to be that my typedef is not working properly in my sql-query. In my class it is working fine. (Note the typedef-line in the hibernate-mapping shown above)
Hibernate-version I have to use: 3.2.7.ga
as stated in my edit:
<return-scalar column="alpha" type="com.package.MyUserType"/>
is working fine. The typedef definition is not working for some reason. I didnt find any bug-report like that for my hibernate-version.