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

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

Have Programming Question? Ask it here!

ratna rathor
Hibernate HQL query by using like operator.
1 Answer(s)      2 years and 3 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.salary, emp.dateOfJoin from Employee emp WHERE like 'R%'";
        Query query=session.createQuery(hql);
List<Object> objectList = query.list();
        Iterator iterator = objectList.iterator();
            Object []obj = (Object[]);


Related Tutorials/Questions & Answers:
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
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
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 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
Hibernate Query - Hibernate
Hibernate Query  Hibernate Query
delete query problem - Hibernate
'"; Query query = sess.createQuery(hql) query.executeUpate(); // int row..., String hql = "delete from Insurance insurance where id = 2"; Query query = sess.createQuery(hql); int row = query.executeUpdate
on hibernate query language - Hibernate
on hibernate query language  Display the contents of 2 fields in a table in a single column using SQL statement.Thanks!  Hi friend,read for more information,
Named ? SQL query in hibernate
Named ? SQL query in hibernate  What is Named SQL query in hibernate?   You can put all the HQL into the XML mapping file rather than...; </hibernate-mapping> Now you can use it as below: Query query
Please convert this SQL query to hibernate - Hibernate
Please convert this SQL query to hibernate  I have a SQl query, which needs to be converted to HQL query, but i am not successfull, please help me...:// http
Problem in updating query in Hibernate - Hibernate
Problem in updating query in Hibernate  Hi, I have used a query to update the existing columns of one table. The query updates the records..., Please visit the following link:
how to debug parameters in the hibernate query
how to debug parameters in the hibernate query  how to debug parameters in the hibernate query
how do i use sql like query in my jsp page
how do i use sql like query in my jsp page  how do i use sql like query in my jsp page   Hi Friend, Try the following code: <%@ page... where name like 'a%'"); while({ out.println(rs.getString("name")+"<
find SQL query created by Criteria - Hibernate
find SQL query created by Criteria  Hi there, I am new to hibernate and want to know if I have some code like this... Criteria criteria = p...   Hi, If you are using tomcat then look for the catalina.out
Using of Hibernate - Hibernate
Using of Hibernate  I have a requirement that my table names are dynamic. For example suppose we have two different court using this system then we... friend,read for more information.
Hibernate code - Hibernate
Hibernate code   how to write hql query for retriveing data from multiple tables
hibernate - Hibernate
hibernate   hi,can any one tell me how to get SQL query in hibernate, when hql fire it will create sql in console when hibernate.cfg.xml property will true, but i want SQL query in one variable how to get it... Thanks satish
Using Hibernate <generator> to generate id incrementally - Struts
Using Hibernate to generate id incrementally  Hi All, How to increment id using Hibernate ( or if any other) to generate id. I am using... this it executes the query like selecting the max(id) value from the database
Create primary key using hibernate
Create primary key using hibernate  How to create primary key using hibernate?   The id element describes the primary key for the persistent class and how the key value is generated.   <id name="id
Hibernate - Hibernate
prog using hibernate query   Hibernate update query This will show you how to update records in hibernate! regards Meeya
Java operator
Java operator  What are the legal operands of the instanceof operator
Java operator
Java operator  What is the difference between the prefix and postfix forms of the ++ operator
hibernate over Jdbc
) Hibernate is data base independent 2) Hibernate provides its own query language called HQL which eliminates the need to learn sql queries 3) Hibernate provides...hibernate over Jdbc  Why use hibernate over Jdbc?   
Java - Hibernate Interview Questions
Java  how to write a sql join in hibernate query language?  Hi Friend, Please visit the following link for more help on the HQL join and many more examples: http
hibernate - Hibernate
hibernate  hi i am new to hibernate. i wan to run a select query...(); //Using from Clause String SQL_QUERY ="from Insurance insurance... Deepak Kumar * * * Select HQL Example */ public
create , edit MS WORD like document file using Java Swing - Swing AWT
create , edit MS WORD like document file using Java Swing   In my..., font style etc. I want this text in JTextArea to be saved to MS WORD like...? I am using Java SWING. Plz. email your answer
hibernate - Hibernate
hibernate  how to write join quaries using hql  Hi satish I am sending links to you where u can find the solution regarding your query:
hibernate - Hibernate
(); //Create Select Clause HQL String SQL_QUERY ="Select Branches.branch_id from Branches branches"; Query query... Hibernate; import org.hibernate.Session; import org.hibernate.*; import
Hibernate - Hibernate using hibernate(Schema name Express) In MDM i am connecting to aracle server with IP using hibernate(Schema name :mdm) So here i... will be in mdm mdm schema my query will be like this "from
Reg Hibernate in Myeclipse - Hibernate
Reg Hibernate in Myeclipse  Hi, My table name is user... without any error. I opened HQL editor and executed from User My output is like this: com.myeclipse.hibernate.User.17cd6ad
hibernate - Hibernate
hibernate  what is hibernate and how to make a pc hibernating?  Hi friend, Hibernate is based on object oriented concept like java... .properties file and in hibernate we use .xml file ,which is a better approach. We
PHP Array Operator
, equality etc. '+' operator is used to get the union of two arrays... are same like '= =' checks the equality, '= = =' checks
hibernate code problem - Hibernate
hibernate code problem  String SQL_QUERY =" from Insurance as insurance where insurance. lngInsuranceId='1'"; Query query = session.createQuery (SQL_QUERY); for(Iterator it=query.iterate() ;it.hasNext
Hibernate code problem - Hibernate
Hibernate code problem  Hai, iam working on simple login application using hibernate in spring. I've used Spring dependency injection too.I struck at DAO(data access Object)layer while executing the select statement in HQL
hibernate - Hibernate
hibernate  is there any tutorial using hibernate and netbeans to do a web application add,update,delete,select   Hi friend, For hibernate tutorial visit to :
What does the delete operator do?
What does the delete operator do?  What does the delete operator do
Explain the ternary conditional operator in PHP?
Explain the ternary conditional operator in PHP?  Explain the ternary conditional operator in PHP
hibernate  how to uses optional column in hibernate
Hibernate - Hibernate
Hibernate  how to call the stored procedure in mysql database server using hibernate..??  Hi Friend, Please visit the following link: Thanks
hibernate - Hibernate
hibernate    what is the lazy Loading in hibernate? can you give the example table ?  Lazy Loading in Hibernate In Hibernate, Lazy.... The main purpose of using lazy loading is to increase the efficiency
Operator - Java Beginners
Operator  Write a program to compute division of 2 without using any arithmetical oprerator.//[IT 3nd semester
PHP Bitwise Operator
Learn PHP Bitwise Operator: It is another kind of operator ,called bitwise operator and  supported by PHP. It is so called because instead of operating on the integer value, it works on the binary number, like if we want to perform
Hibernate - Hibernate
Hibernate Features  Hibernate features in eclipse
query in JDBC
query in JDBC  What are the steps required to execute a query in JDBC
of Hibernate. I followed all th steps as given in the tutorial, but a build error... hibernate library files are not included in the project build path. Please download the example from Hibernate Getting Started Tutorial. Please follow the steps
PHP Concatenation Operator
The only one string operator in PHP is concatenation operator (.) that is used for putting two string values together; e.g. <?php $txt1=“Hello...? If we look at the code above you see that we used the concatenation operator two
Need for hibernate - Hibernate
of Hibernate are : It uses Object-oriented query language. Transparent...Need for hibernate  Can anyone say why should we go for hibernate?   Hi friend, Advantages of hibernate : It is based on object
PHP Comparison Operator
Comparison Operator: It is another kind of operator supported by PHP, with this operator you can compare two variables, whether the variables are equal... a special type of operator (= = =) which compares two variables and their data type
hibernate - Hibernate
hibernate  pl send me hibernate interview questions
PHP Instanceof Operator
Type Operators: This is another kind of operator, instanceof, this operator is used to check an object that whether this is an object of specified class or not. instanceof can also be used to determine whether an object of a class