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

 
 


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

How use like operator in HQL?

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 Pages:
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
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
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
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
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
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
HQL
HQL  What is the HQL in hibernate ? Explain the use of HQL.   Hi Friend, Please visit on this link....... Hibernate Query Language
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
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
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
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
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
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
like operator
like operator  how to select exact value using like operator in php
What is Hibernate Query Language (HQL)?
What is Hibernate Query Language (HQL)?  Hi, What is Hibernate Query Language (HQL)? thanks
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
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
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: The below
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
Hibernate Query Language
Hibernate Query Language           Introduction to Hibernate Query Language Hibernate Query Language or HQL for short is extremely powerful query language. HQL
Mysql Like Operator
in select query. The like comparison Operator in SQL allows you to match any... Mysql Like Operator      ... from 'Mysql Like Operator'.To grasp this exammple we create a table'employee1
Mysql Like Operator
matching in select query. The like comparison Operator in SQL allows you to match... Mysql Like Operator      ...; example from 'Mysql Like Operator'.To grasp this exammple we create
SQL AND Like Operator
SQL AND Like Operator       The SQL AND Like Operator work with WHERE clause to find and search  for a specified pattern in a column of table. The AND Like Operator
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
Hibernate insert Query
Hibernate insert Query In this tutorial you will learn about how to use HQL insert query. INSERT query in HQL is used to insert the records into the database table. INSERT query of HQL is just like the INSERT query used in SQL
SQL AND Like Operator
SQL AND Like Operator       The SQL AND Like Operator work with WHERE clause to find and search  for a specified pattern in a column of table. The AND Like Operator
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
hibernate delete query :
hibernate delete query :   Hi, I m using Hibernate 3 + javadb my table is like: CREATE table APP.BIDS ( BID_ID INTEGER NOT NULL... APP.BIDS where BID_ID = 16"; Query query = session.createQuery(query1); int row
Hibernate Like Query
This section illustrate hibernate like query with example
sum and avg function using HQL.
sum and avg function using HQL.  How to use sum and avg function in HQL?   HQL supports many aggregate functions. Sum and avg are some...(emp.salary) FROM Employee emp"; Query sumQuery = session.createQuery
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
HQL Sample
technical stuff very easily. The HQL or Hibernate Query language is very powerful and can be easily used to develop complex query in Java program. HQL is then translated into SQL by the ORM component of Hibernate. HQL is very powerful
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
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
Hibernate Query Language
Hibernate Query Language   Explain Hibernate Query Language(HQL) of Hibernate?   Hi Samar, Hibernate Query Language is a library.... Compared with SQL, however, HQL is fully object-oriented and understands notions
Hibernate query - Hibernate Interview Questions
Hibernate query  Hi,In my one interview i face one question that is how to write query without using hql and sql.If any body knows please give the answer thank u
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
Hibernate delete Query
Hibernate delete Query In this tutorial you will learn how to use HQL delete query in Hibernate. In this section we are discussing about the HQL delete query... to use HQL delete query. An example is being given regarding how delete query may
Count distinct value in HQL.
Count distinct value in HQL.  How do you count distinct value in HQL...) FROM Employee emp"; Query countQuery = session.createQuery(countHql...)); } } Output: Hibernate: select count(distinct employee0_.salary) as col_0_0
Hibernate Isolation Query. - Hibernate
Hibernate Isolation Query.  Hi, Am Using HibernateORM with JBOSS server and SQLSERVER.I have a transaction of 20 MB, when it is getting processed... the data as it is locked by the previous thread,but i would like to show
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
HQL order by.
HQL order by.  HQL Order by query giving problem.   Order...(); String hql="Select emp FROM Employee emp ORDER BY name"; Query query... into descending order you can follow the following HQL ? String hql="Select emp FROM
Hibernate Delete Query
In this section we will discuss how to delete record of table using HQL
HQL group By.
"; Query query=session.createQuery(hql); query.setResultTransformer...HQL group By.  How to use group by in HQL?   In general... order. It allows the Hibernate to fetch information from the database and group
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
Mysql Date like
| +-------+---------+------------+ 7 rows in set (0.00 sec) Query to view data using date like... Mysql Date like       The Like Operator is used in pattern matching by comparison with character
Hibernate Query Language
to Hibernate Query Language Hibernate Query Language or HQL for short is extremely powerful query language. HQL is much like SQL and are case...Hibernate Query Language      
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

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.