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 |
| 6 | Life Insurance | 900 | 2003-01-01 00:00:00 |
| 7 | Travel Insurance | 2000 | 2005-02-02 00:00:00 |
Here is the code of the class using "ge" Expression :
package roseindia.tutorial.hibernate;
|
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 |
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.
Ask Questions? Discuss: Hibernate Criteria Expression (ge) View All Comments
Post your Comment