Solved

Hibernate filters

Posted on 2006-10-19
3
673 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Custom Java Application connects to database: Which one of the 20? 4 44
login form jsp example 2 56
Java: anonymous class 4 39
intellij error 2 33
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

697 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