Solved

Hibernate filters

Posted on 2006-10-19
3
683 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

696 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