Case-insensitive equals using Hibernate Criteria.

Ads
 

Case-insensitive equals using Hibernate Criteria.

How to use Case-insensitive equals with Hibernate Criteria?

View Answers

May 29, 2012 at 6:39 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-

package net.roseindia.main;
import java.util.*;
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 CaseInsensitiveEqual{
    public static void main(String[] args) {
    SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
    Session session = sessionFactory.openSession();

    Criteria criteria = session.createCriteria(Employee.class);
    criteria.add(Restrictions.eq("name", "ron").ignoreCase());
    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: Here

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

Checks the property ‚??name‚?? for ‚??ron‚?? without caring the case.

Ads









Related Tutorials/Questions & Answers:
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 ordering using Hibernate Criteria.
Case-insensitive ordering using Hibernate Criteria.  What is Case-insensitive ordering in Hibernate Criteria
Advertisements
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 search using Hibernate Query Language(HQL).
Case-insensitive search using Hibernate Query Language(HQL).  What is Case-insensitive search using Hibernate Query Language
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
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: ORDER BY using Criteria API.
Hibernate: ORDER BY using Criteria API.  How to display record in order using Criteria API?   Hibernate Criteria API provides an easy way of building dynamic query on the persistence database. The hibernate criteria
Hibernate criteria query using Max()
Hibernate criteria query using Max()  What is Hibernate criteria query using Max()?   You can find out maximum value in hibernate criteria... in ?org.hibernate.criterion?. For using Projection object in our Criteria, we have to call
Hibernate criteria query using Min().
Hibernate criteria query using Min().  How to find minimum value in Hibernate criteria query using Projection?   You can find out minimum value in hibernate criteria by using projection. Projection is an interface
Hibernate criteria query using avg()
Hibernate criteria query using avg()  How to calculate average in Hibernate criteria query using Projection?   You can calculate average of any numeric values in hibernate criteria by using projection. Projection
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
Hibernate criteria example using struts2
Hibernate criteria example using struts2 This hibernate criteria example using struts2 is used for defining the basics of criteria. The hibernate criteria... create query without HQL. In this hibernate criteria example using struts2, we
Hibernate Criteria Examples
of using Hibernate Criteria query. With the help of criteria query you can... Hibernate Criteria Count Hibernate Criteria Count Distinct Hibernate Criteria Case Insensitive Hibernate Criteria For Date Hibernate Criteria Distinct
ModuleNotFoundError: No module named 'case_insensitive_dict'
ModuleNotFoundError: No module named 'case_insensitive_dict'  Hi...: No module named 'case_insensitive_dict' How to remove the ModuleNotFoundError: No module named 'case_insensitive_dict' error? Thanks   Hi
ModuleNotFoundError: No module named 'case_insensitive_dict'
ModuleNotFoundError: No module named 'case_insensitive_dict'  Hi...: No module named 'case_insensitive_dict' How to remove the ModuleNotFoundError: No module named 'case_insensitive_dict' error? Thanks   Hi
How to get unique list in Hibernate using Criteria Query?
How to get unique list in Hibernate using Criteria Query?  Hi, Share me the example code for getting Unique List in Hibernate through Criteria Query? Thanks
Hibernate Criteria :Ordering the results
In this section, you will learn about ordering the results using Hibernate Criteria query
Hibernate Detached Criteria Subquery
In this section we will discuss how to write subqueries using Detached Criteria in Hibernate
Examples of Hibernate Criteria Query
Criteria Greater Than Hibernate Criteria Group By Hibernate Criteria Case Insensitive Hibernate Criteria Join Hibernate Criteria Join Hibernate Criteria...Example code and running projects of Hibernate Criteria Query Here
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate
Hibernate Criteria With Collections Example
Hibernate Criteria With Collections Example  Good code of Hibernate Criteria With Collections Example. Thanks   Example program of using Hibernate Criteria With Collections in your Java project. Check the tutorial
Hibernate criteria average Example
Hibernate criteria average Example   How to find the average... using criteria. For this you have to use Projections.avg() in your program. Check the tutorial Hibernate criteria avg.. Check the Latest tutorials, articles
ModuleNotFoundError: No module named 'odoo10-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo10-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo10-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo11-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo11-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo11-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo13-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo13-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo13-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
Hibernate criteria disjunction.
Hibernate criteria disjunction.  What is criteria disjunction in hibernate
Hibernate Detached Criteria Example
Hibernate Detached Criteria Example  can anyone share me the source code of using detached Criteria in Hibernate? Thanks   Hi, If you are looking for the Example program of using Hibernate Detached Criteria
Criteria Query Examples in Hibernate
Criteria Query Examples in Hibernate  How to use the Criteria Query in Hibernate? How to select the data using Criteria Query of Hibernate? Thanks... Criteria Query in Hibernate with Examples code. Check the tutorial Criteria Query

Ads