Wednesday, June 27, 2012

Invalid filter-parameter name format

       The following error is occuring while appling filter in hibernate mapping.

ERROR [27-Jun-2012 19:26:33] (PatientAction:414) - Invalid filter-parameter name format
com.radaptive.common.exception.RttException: Invalid filter-parameter name format
at com.radaptive.common.ExceptionInterceptor.invoke(ExceptionInterceptor.java:100)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

Set the filter in hibernate session:
----------------------------------------------------

                 Filter filter = session.enableFilter("tenantFilter");                                     
                 filter.setParameterList("tenantColParam",relatedTenantIdsList);

Mapping file:
--------------------
<?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>
    <class
        entity-name="Ticket"
        table="RT_TICKET_CORE"
        dynamic-update="true"
    >
    <filter name="tenantFilter" condition="TENANTID IN (:tenantColParam) "/>
   </class>
         <filter-def name="tenantFilter">
            <filter-param name="tenantColParam" type="java.lang.String"/>
        </filter-def>
</hibernate-mapping>

HQL used:
---------------
 getHibernateTemplate().find("select CONCAT(patient.patientName||' ('||substring(patient.gender,1,1)||'/'||patient.age||')'||':'||patient.patientId) from Patient as patient where patient.id='"+patientId+"'").get(0)


Solution:
======

   If the HQL query is having ':' , It will throw the exception like this since it is searching for the filter(in the name given next to :) in mapping file.
Remove the colon(:) and run then it will work successfully.

No comments:

Post a Comment