Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate Hibernate HQL query by using like operator.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


ratna rathor
Hibernate HQL query by using like operator.
1 Answer(s)      2 years and 6 months ago
Posted in : Hibernate


How use like operator in HQL?


Advertisement
View Answers

May 31, 2012 at 6:50 PM


HQL stands for Hibernate Query Language, provided by Hibernate. It is minimal object oriented, similar to SQL.It works like a bridge between database and application. Like operator is used for string pattern matching. The percent character(%) is used before or after the character/substring.

package net.roseindia.main;

import java.util.*;
import net.roseindia.table.Employee;
import net.roseindia.util.ConnectionUtil;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;

public class MainClass {
    public static void main(String[] args) {
        SessionFactory sessionFactory = ConnectionUtil.getSessionFactory();
        Session session = sessionFactory.openSession();

        String hql="SELECT emp.name, emp.salary, emp.dateOfJoin from Employee emp WHERE emp.name like 'R%'";
        Query query=session.createQuery(hql);
List<Object> objectList = query.list();
        Iterator iterator = objectList.iterator();
        while(iterator.hasNext()){          
            Object []obj = (Object[])iterator.next();
            System.out.println(obj[0]);
            System.out.println(obj[1]);
            System.out.println(obj[2]);
        }

        session.close();
    }
}


Related Tutorials/Questions & Answers:
Hibernate HQL query by using like operator.
Hibernate HQL query by using like operator.  How use like operator in HQL?   HQL stands for Hibernate Query Language, provided by Hibernate... database and application. Like operator is used for string pattern matching
Hibernate Query Language (HQL)
Hibernate Query Language (HQL)  What is Hibernate Query Language (HQL)?   HQL is much like SQL and are case-insensitive, except for the names of the Java Classes and properties. Hibernate Query Language is used
Advertisements
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
What is Hibernate Query Language (HQL)?
What is Hibernate Query Language (HQL)?  Hi, What is Hibernate Query Language (HQL)? thanks
Delete Query using HQL
Delete Query using HQL  Can we write 'AND' with 'WHERE' clause in delete query using HQL? For example: delete from table name where field1... a look at the following link: Hibernate Delete Query
Delete HQL query - Hibernate
Delete HQL query  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query class has method executeUpate() & not executeUpdate(); log4j:WARN No appenders
HQL, Hibernate Query Language
HQL - Hibernate Query Language In this tutorial on HQL we will learn how...? The HQL stands for Hibernate Query Language, which is inspired by the SQL... the programmer to write Query using the persistence entity. The HQL is fully
Hibernate Like Query
This section illustrate hibernate like query with example
How to use AND operator in hibernate Detached criteria query?
How to use AND operator in hibernate Detached criteria query?  How to use AND operator in hibernate Detached criteria query
Hibernate Query Language
; Hibernate Query Language or HQL for short is extremely powerful 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
HQL Query
HQL Query  Hibernate query language: How to use a left join in Hibernate query language. Can somebody help with an example. I am getting a unexpected token error in HQL Query tool If I use joins
How to use AND OR operator in hibernate Detached criteria query?
How to use AND OR operator in hibernate Detached criteria query?  How to use AND OR operator in hibernate Detached criteria query?   You can use AND, OR operator in hibernate detachedCriteria through
HQL query
HQL query  how to select only password based on username using HQL query from login table where uname and paswrd are two column names
HQL in hibernate ? Explain the use of HQL.
HQL in hibernate ? Explain the use of HQL.  What is the HQL in hibernate ? Explain the use of HQL.   HQL stands for Hibernate Query... like SQL.Its query is case-insensitive expect we are using the java class
Introduction To Hibernate Query Language (HQL)
Introduction To Hibernate Query Language (HQL) In this tutorial you will learn about Hibernate Query Language. HQL is an abbreviation of Hibernate Query... as roseindia.net.Hibernateexample. Benefits of Hibernate Query Language is : Learning (HQL) Query
How to use OR operator in hibernate Detached criteria query?
How to use OR operator in hibernate Detached criteria query?  How to use OR operator in hibernate Detached criteria query?   You can use OR operator in hibernate detachedCriteria through Restrictions.disjunction
like operator
like operator  how to select exact value using like operator in php
LIKE Operator
SQL Like Operator Query Now we want to select the persons name those name... LIKE Operator       The LIKE operator is used for searching  a specified pattern
Hibernate Query Language
Hibernate Query Language           Introduction to Hibernate Query Language Hibernate Query Language or HQL for short is extremely powerful query language. HQL
Hibernate delete HQL - Hibernate
Hibernate delete HQL  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query class has method executeUpate() & not executeUpdate
select query using hibernate
select query using hibernate  Hi, can any one tell me to select records from table using hibernate. Thanks   Please visit the following link: Hibernate Tutorials The above link will provide you different
PHP SQL LIKE Operator
PHP SQL LIKE Operator       This example illustrates how to use the like operator in sql query. The LIKE operator is used in a WHERE clause to search for  matching strings based
HQL Query in execute method of Struts2
data from database using hql. And where I need to write the hql query...HQL Query in execute method of Struts2  I am making login page in struts2 and using hibernate . Now I wants to pull user name and password from
Hibernate-HQL subquery - Hibernate
Hibernate-HQL subquery  Hi, I need to fetch latest 5 records from a table.My query goes here. select * from (select * from STATUS...) where ROWNUM <=5; -------------------------- I need an equivalent query
AND operator in hibernate.
AND operator in hibernate.  How to use AND operator in hibernate
OR operator in hibernate.
OR operator in hibernate.  How to use OR operator in hibernate
PHP SQL LIKE Operator
PHP SQL LIKE Operator This example illustrates how to use the like operator in sql query. The LIKE operator is used in a WHERE clause to search... like 's%'"); In this query we want to find the name which end with h
how to search for string using LIKE operator instead of integer?
how to search for string using LIKE operator instead of integer?  ... "table2" details. in other words, my "dbtable.jsp" query should be like this (select * from items where itemname LIKE '"+id). and my detail file "table2.jsp
LIKE Operator
Like Operator Query Now we want to select the persons name those name starts... LIKE Operator       The LIKE operator is used for searching  a specified pattern
Mysql Like Operator
Mysql Like Operator       Mysql Like Operator is used to compare a part of string using the % wild... to view data from Table named employee1 using like command: The below Query
Mysql Like Operator
Mysql Like Operator       Mysql Like Operator is used to compare a part of string using...) Query to view data from Table named employee1 using like command
 

 

 

DMCA.com