[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Hibernate filters

Posted on 2006-10-19
3
Medium Priority
?
691 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 2000 total points
ID: 17771221
Instead of java.lang.Character try using the simple char type

Java - char
Hibernate - character
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

650 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