Home Answers Viewqa Hibernate Hibernate Criteria Case Insensitive Search.

 
 


ratna rathor
Hibernate Criteria Case Insensitive Search.
1 Answer(s)      11 months ago
Posted in : Hibernate

How to use Case Insensitive Search in Hibernate?

View Answers

May 29, 2012 at 6:32 PM


The Case Insensitive ignores the case of the latter. It Selects all the records of the table related to the given parameters.

Create hibernate configuration file (hibernate.cfg.xml) and save it in the same folder where you are going to save your source code.

Now create Persistent class Employee.javaâ??Hibernate uses the Plain Old Java Object (POJO) classes to map to the database table. Next create an util class as HibernateUtil.java

Here is your MainClass-

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.roseindia.table.Employee;
import net.roseindia.util.HibernateUtil;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;

public class MainClass {
    public static void main(String[] args) {
        SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
        Session session = sessionFactory.openSession();
        Criteria criteria =session.createCriteria(Employee.class);
        criteria.add(Restrictions.like("name", "r%"));
        List<Employee> employeeList = new ArrayList<Employee>();
        employeeList = criteria.list();
        Iterator it = employeeList.iterator();
        while (it.hasNext()) {
            Employee employee = (Employee) it.next();
            System.out.println(employee.getName());
        }
        session.close();
    }
}

Description: - Hibernate criteria is used here as alternative to HQL. The Criteria interface can be obtained using the Session.createCriteria() method.

criteria.add(Restrictions.like("name", "r%"));
//It selects all names that start with â??râ?? character without caring of case sensitivity.

Output:

Hibernate: select this_.emp_id as emp1_0_0_, this_.date_of_join as date2_0_0_, this_.name as name0_0_, this_.salary as salary0_0_ from employee this_ where this_.name like ?
Ron
Roxi

You can also Use Restrictions.eq().ignoreCase(). It checks equality, ignoring the case. Ex.

criteria.add(Restrictions.eq("name", "ron").ignoreCase());









Related Pages:
Hibernate Criteria Case Insensitive Search.
Hibernate Criteria Case Insensitive Search.  How to use Case Insensitive Search in Hibernate?   The Case Insensitive ignores the case...()); } session.close(); } } Description: - Hibernate criteria is used here
Hibernate Criteria Case Insensitive
Hibernate Criteria Case Insensitive The Case Insensitive ignores the case... = criteria.list(); An example of Case insensitive is given below please consider... parameters Criteria criteria = session.createCriteria(Student.class
Case-insensitive ordering using Hibernate Criteria.
Case-insensitive ordering using Hibernate Criteria.  What is Case-insensitive ordering in Hibernate Criteria
Case-insensitive equals using Hibernate Criteria.
Case-insensitive equals using Hibernate Criteria.  How to use Case-insensitive equals with Hibernate Criteria?   The Case Insensitive ignores the case of the latter. It Selects all the records of the table related
Case-insensitive search using Hibernate Query Language(HQL).
Case-insensitive search using Hibernate Query Language(HQL).  What is Case-insensitive search using Hibernate Query Language
Hibernate Criteria Examples
Hibernate Criteria Count Hibernate Criteria Count Distinct Hibernate Criteria Case Insensitive Hibernate Criteria For Date Hibernate Criteria Distinct...Hibernate Criteria Examples In this section we are giving many example
indexof case insensitive java
indexof case insensitive java  Hi, I have to use the indexOf function on String class in Java. I am looking for indexof case insensitive java example. Share the code with me. Thanks   Hi, You can convert both
Case-sensitive equals using Hibernate Criteria.
Case-sensitive equals using Hibernate Criteria.  How to check for case sensitive equals in Hibernate criteria?   package net.roseindia.main... : 220000 Date of Join : 2001-02-03 00:00:00.0 Description : Hibernate Criteria API
Criteria in Hibernate
Criteria in Hibernate  What is Criteria in Hibernate?   Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like "search" screens
Hibernate case sensitive comparison.
Hibernate case sensitive comparison.  How to check for case sensitive in Hibernate criteria?   package net.roseindia.main; import...(); Session session = sessionFactory.openSession(); Criteria criteria
Hibernate Criteria Lower
Hibernate Criteria Lower The Hibernate Criteria Lower Ignore a the case. You... = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = session.createCriteria... it will display message as shown below: Hibernate: select this_.roll
Hibernate criteria for date.
Hibernate criteria for date. In this example, you will see how to create criteria for date. This example will access record from data, that is  greater then or equal to given date. It is like as search by data. CriteriaDAO.java
Hibernate Criteria Query Example
limitations. Criteria Query is used mostly in case of multi criteria search screens... Hibernate Criteria Query Example   ... for Criteria instances. Here is a simple example of Hibernate Criterial Query:  
Hibernate Query Language
query language. HQL is much like SQL  and are case-insensitive, except... be used while using Hibernate. These are Query By Criteria (QBC) and Query BY Example... Hibernate Query Language      
Hibernate Criteria
. It is used where search on multi criteria required, becouse Hibernate Query...Hibernate Criteria org.hibernate.Criteria is an interface which is very... the first criteria to include the WHERE sysntax. Hibernate Criteria is very convenient
hibernate criteria 'And' 'or' condition Example
hibernate criteria 'And' 'or' condition Example In this Example, We will discuss about hibernate criteria query, In this example we create a criteria instance and implement the factory methods for obtaining certain built
criteria
criteria in hibernate?   Here is a code that finds the maximum salary among the employees from the database using Hibernate Criteria. Criteria criteria...(Projections.max("salary")); For more information, visit the following link: Hibernate
criteria api
to the named property. * Restrictions.ilike("title", "Twist%") - A case-insensitive "like...criteria api  what is the purpose of Restrictions class   ... restrictions that can also be use to narrow our Criteria query result
Hibernate Criteria Query Example
Hibernate Criteria Query Example In this Example, We will discuss about hibernate criteria query, The interface org.hibernate.Criteria is used to create the criterion for the search. In this example we create a criteria instance
hibernate criteria date between
hibernate criteria Date Between Example In this Tutorial, We will discuss about hibernate criteria query, The interface org.hibernate.criterion.Restrictions  is used to create the criterion for the search. In this example we
Hibernate Criteria setFirstResult Example
Hibernate Criteria setFirstResult Example In this Example, We will discuss about hibernate criteria query, The interface org.hibernate.Criteria is used to create the criterion for the search. In this example we create
Hibernate Criteria Equal Example
Hibernate Criteria Equal Example In this Example, We will discuss about hibernate criteria query, The interface.... In this example we create a criteria instance and implement the factory methods
Hibernate Criteria NotEqual Example
Hibernate Criteria NotEqual Example In this Example, We will discuss about hibernate criteria query, The interface.... In this example we create a criteria instance and implement the factory methods
Hibernate Criteria Between
Hibernate Criteria Between The Criteria Between method provides some numeric range to search result. Suppose you want to search student record whose roll...=criteria.list(); An example of Hibernate Criteria Between is given below
Hibernate Criteria Distinct
Hibernate Criteria Distinct The Hibernate Criteria Distinct API search... from the student table. The same thing can be written using Criteria distinct API as follows Criteria criteria = session.createCriteria(Student.class
Hibernate Criteria Like and Between Example
Hibernate Criteria Like and Between Example In this Example, We will discuss about hibernate criteria query, The interface org.hibernate.criterion.Restrictions  is used to create the criterion for the search
hibernate criteria Unique Result Example
hibernate criteria Unique Result Example In this Example, We will discuss about hibernate criteria query, In this example we create a criteria instance... method. In This example search the result according to Criteria
Hibernate Criteria restrictions Query Example
Hibernate Criteria restrictions Query Example In this Example, We will discuss about hibernate criteria query, The interface org.hibernate.Criteria is used to create the criterion for the search. In this example we create
Hibernate criteria disjunction.
Hibernate criteria disjunction.  What is criteria disjunction in hibernate
Hibernate Creating criteria instance
Hibernate Creating criteria instance In this section you will learn about the creating of criteria instance in Hibernate. An instance of Criteria is created... for instantiating the Criteria. Example : An example is being given below
SEARCH
SEARCH  how can we do search in jsp...? option for search criteria like name and DOB...   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Hibernate Criteria
In this tutorial we are going to discuss Hibernate Criteria with example
Hibernate Criteria Or
In this section we are going to discuss Hibernate Criteria Or with example
Hibernate-Criteria - Hibernate
Hibernate-Criteria  Hi friends, I am new to hibernate. Im learning it. When im using Criteria im getting exception tht "Criteria cannot... for more information. http://www.roseindia.net/hibernate/hibernate-between
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate
Hibernate Criteria isNotNull Example
Hibernate Criteria isNotNull Example In this Example, We will discuss about hibernate criteria query, The interface org.hibernate.criterion.Restrictions.... In this example we create a criteria instance and implement the factory methods
Hibernate Criteria Queries - Hibernate
Hibernate Criteria Queries  Can I use the Hibernate Criteria Query...().buildSessionFactory(); session = sessionFactory.openSession(); Criteria crit... Configuration(); // configuring hibernate SessionFactory
hibernate criteria or condition Example
hibernate criteria or condition Example In this Example, We will discuss about hibernate criteria query, In this example we create a criteria instance... method. In This example search the result according to multiple Restriction 
hibernate criteria disjunction
hibernate criteria Disjunction In this Example, We will discuss about hibernate criteria query, In this example we create a criteria instance and implement.... In This example search the result according to disjunction. The disjunction
Hibernate Query Language
Hibernate Query Language      ... learned about Hibernate Query Language and its different kind of clauses. Lets... to Hibernate Query Language Hibernate Query Language or HQL for short
Criteria Query Examples
Criteria Query Examples       In the last lesson we learnt how to use Criteria Query to select... by Criteria interface can be used with the help of Restrictions to restrict the records
Developing Search Engine in Java
in Java technologies. We will be using Hibernate Search for developing the search... in case of an obscure query. A typical crawler based search engine has three... for the web pages based on some search criteria and read them and also goes
hibernate criteria Distinct Result Example
hibernate criteria Distinct Result Example In this Example, We will discuss about hibernate criteria query, In this example we create a criteria instance... method. In This example search the result according to Criteria
hibernate criteria Distinct_Root_Entity
hibernate criteria Distinct_Root_Entity In this Tutorial, We will discuss about hibernate criteria query, In this example we create a criteria instance... method. In This example search the result according to Criteria
Hibernate criteria count.
Hibernate criteria count.  How do we count rows using criteria in hibernate?   We can get the rows count using the Projections. My code is like this: Criteria criteria = session.createCriteria(getReferenceClass
Hibernate Detached Criteria
This section is good discussion about hibernate detached criteria
Hibernate criteria query
Hibernate criteria query  Hi... I need criteria query like query... a.countryId=c.Chrono and a.groupId=b.Chrono and a.type =1 "); like this in hibernate criteria example. Thanks in advance.   Have a look at the following link
Using sum() in hibernate criteria.
Using sum() in hibernate criteria.  How to calculate sum() in hibernate criteria by using projection?   You can calculate sum of any numeric value in hibernate criteria by using projection. Projection is an interface
Hibernate Search - Hibernate
topics... these dayes i am working in "Hibernate Search" it is new and i can't... and offcourse to others who are new and want to integrate Hibernate Search... which leads me to integrate the Hibernate search in my exsisting hibernate
Criteria with Multiple Tables - Hibernate
Criteria with Multiple Tables  I am using Hibernates Criteria. How to get Joins using Criteria? e.g. instead of below query i want to use criteria...://www.roseindia.net/hibernate/ Hope that it will be helpful for you. Thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.