Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Hibernate
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Hibernate Criteria Expression (ge)

                         

In this section, you will learn to use the "ge" method. This is one of the most important  method that is used to apply a "greater than or equal" constraint to the named property.

Expressions: The Hibernate Criteria API supports a rich set of comparison operators. Some standard SQL operators are =, <, ?, >, ?. That supports ge() method in Expression class.

In this tutorial, "ge" is used with the Long object (ID). It takes two parameters e.g.  ge("property_name",Object val).

Table Name: insurance

ID insurance_name invested_amount investement_date
2 Life Insurance 25000 0000-00-00 00:00:00
1 Givan Dhara 20000  2007-07-30 17:29:05
3 Life Insurance  500 2005-10-15 00:00:00
4 Car Insurance   2500 2005-01-01 00:00:00
5 Dental Insurance 500 2004-01-01 00:00:00
Life Insurance 900 2003-01-01 00:00:00
Travel Insurance  2000  2005-02-02 00:00:00

Here is the code of the class using "ge" Expression :

package roseindia.tutorial.hibernate;

import java.util.Iterator;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Expression;

public class HibernateCriteriaQueryExpressionGe {

  /**
   @param args
   */
  public static void main(String[] args) {
    // TODO Auto-generated method stub

    Session sess = null;
    try{
      SessionFactory fact = new 
Configuration
().configure().buildSessionFactory();
      sess = fact.openSession();
      Criteria crit = 
sess.createCriteria
(Insurance.class);
        crit.add(Expression.ge
(
"lngInsuranceId",new Long(3)));
        List list = crit.list();
        for(Iterator it = 
list.iterator
();it.hasNext();){
          Insurance ins = 
(
Insurance)it.next();
          System.out.println(
"Id: " + ins.getLngInsuranceId());
          System.out.println(
"Insurance Name: " 
+ ins.getInsuranceName());
          System.out.println(
"Insurance Amount: " 
+ ins.getInvestementAmount());
          System.out.println(
"Investement Date: " + ins.getInvestementDate());
        }
        sess.clear();
    }
    catch(Exception e){
      System.out.println(e.getMessage());
    }
  }
}

 Download this Code.

Output:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).

log4j:WARN Please initialize the log4j system properly.

Hibernate: select this_.ID as ID0_0_, this_.insurance_name as insurance2_0_0_, this_.invested_amount as invested3_0_0_, this_.investement_date as investem4_0_0_ from insurance this_ where this_.ID>=?

Id: 3

Insurance Name: Life Insurance

Insurance Amount: 500

Investement Date: 2005-10-15 00:00:00.0

Id: 4

Insurance Name: Car Insurance

Insurance Amount: 2500

Investement Date: 2005-01-01 00:00:00.0

Id: 5

Insurance Name: Dental Insurance

Insurance Amount: 500

Investement Date: 2004-01-01 00:00:00.0

Id: 6

Insurance Name: Life Insurance

Insurance Amount: 900

Investement Date: 2003-01-01 00:00:00.0

Id: 7

Insurance Name: Travel Insurance

Insurance Amount: 2000

Investement Date: 2005-02-02 00:00:00.0

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
map iteration in jstl
java int array
call à¹?à¸?à¸??à¹?à¸?à
how to read key value
jsp combo box my sql
a simple calculator pr
HOW TO UPLOAD IMAGE FR
jdbc with oraclw sql
how to retrive values
print values from tabl
java questions
periodic table java ap
selected index
Linux Caixa MÑ??Ð??Ñ??
html code for developi
program in java to ins
html sample
write a swing applicat
Photoshop Text Effects
breakÑ?â??â??Ñ??Ñ?â???
Request Object In JSP
if else statement calc
head first EJB
what are the exception
Aะà¸??ะàÂ
ajaxprototypeframework
HTML HTML 4.0 Easy HTM
jdbc with sql
Folder content using j
factorial no.java scri
appending to a file ja
WebObjects
insert query in HQL
how to develop a sampl
static class
Aத�?த�?த�?
How to give color to D
updation of data in th
Sending Data to a Port
struts select tag
XML READER
ibatis
NavigableSet
JDBC (Java Database Co
insert into image
multi-dimensional arra
Applet checkbox exampl
jsp tag
struts2 radio button
procedure in mysql
how to create web appl
Photoshop Effects Imag
Dreamweaver Linking an
password and user name
easy struts eclipse
super class
convert string array t
த���த��?
cookies in a servlet
where we place plug-in
create notepad
command line in java
command button in jsf
Track wireless session
mapping.findForward
Photoshop Tutorial
table grid
insert BFILE data type
Javascript Links and B
abstract.
java Swing button smok
Photoshop Animation Bl
logout page in jsp
weblogic 8.1
get screen width and h
download file using js
list out the advantage
how to use email valid
velocity
change frame font colo
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.