Solved

Hibernate filters

Posted on 2006-10-19
3
669 Views
Last Modified: 2013-11-24
I have the following:
<hibernate-mapping>
    .
    .
    <class name="Persons" table="persons">
        <cache usage="read-only"/>
        <id name="personID" column="ID"/>
        <property name="firstName" column="First_Name"/>
        <property name="middleName" column="Middle_Name"/>
        <property name="lastName" column="Last_Name"/>
        <property name="inActive" column="Deleted_Flag" type="java.lang.Character"/>
        <filter name="activePersons" condition=":ActivePerson.compareTo(inActive) != 0"/>
    </class>
    <filter-def name="activePersons">
        <filter-param name="ActivePerson" type="java.lang.Character"/>
    </filter-def>
</hibernate-mapping>
_______________________________________________________________________________________
public class Persons {
    private int personID;
    private String firstName;
    private String middleName;
    private String lastName;
    private Character inActive;
   
    .
    .
    private Character isInActive() {
        return inActive;
    }

    private void setInActive(Character active) {
        this.inActive = active;
    }
_______________________________________________________________________________________
private void viewSource(int sc) {
        Transaction tx = null;
        Session session = SessionFactoryManager.getCurrentSession(RMSUtility.ROS_DB);
        Criteria criteria;



        tx = session.beginTransaction();
        Filter filter = session.enableFilter("activePersons");
        filter.setParameter("ActivePerson", new Character('Y'));

        criteria = session.createCriteria(Persons.class);
        criteria.add(Restrictions.eq("personID",sc));

        List list = criteria.list();
        Iterator iter = list.iterator();
        if(iter.hasNext())
            System.out.println(iter.next().toString());

        tx.commit();
    }
_________________________________________________________________________________

And I am getting the following error everytime I try to create a List:

Exception in thread "main" java.lang.InternalError: Unable to locate type for filter parameter
      at org.hibernate.impl.SessionImpl.getFilterParameterType(SessionImpl.java:1050)
      at org.hibernate.engine.QueryParameters.processFilters(QueryParameters.java:387)
      at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1530)
      at org.hibernate.loader.Loader.doQuery(Loader.java:661)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
      at org.hibernate.loader.Loader.doList(Loader.java:2145)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
      at org.hibernate.loader.Loader.list(Loader.java:2024)
      at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
      at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
      at rms.utility.EventManager.viewSource(EventManager.java:161)
      at rms.utility.EventManager.main(EventManager.java:105)
0
Comment
Question by:rufassa
3 Comments
 
LVL 8

Accepted Solution

by:
reach2piyush earned 500 total points
ID: 17771221
Instead of java.lang.Character try using the simple char type

Java - char
Hibernate - character
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
stackato and cloud 4 85
servlet doXXX methods 3 49
How to increase Spring boot/Tomcat max file upload size 2 71
map related example 6 48
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question