Hql Operator
QBC Operator
Description
=
Restrictions. eq ()
Equal to equal
Restrictions. Ne ()
Not equal to not equal
>
Restrictions. gt ()
Greater than greater
> =
Restrictions. Ge ()
Greater than or equal to greater than or equal
Restrictions. LT ()
Less than less
Restrictions. Le ()
Less than or equal to less than or equal
Is null
Restrict
Error code://list vlist = This.gethibernatetemplate (). Find ("From Androidcustomer ct where ct.token =" +token);Correct code: List vlist= this.gethibernatetemplate (). Find ("from Androidcustomer a where a.token= '" + token+ "'");Here the token is a string, ( when a string or a date must have a single quotation mark , because in the database query when the use of single quotes)When used as a number, it is not possible to use single quotation marks, because in PL/SQL, when querying and not using
literals 'foo', 69, '2017-01-01 10:00:01. 0'
Java public static final constants eg. color. Tabby
I don't have to explain anything else. Here I just want to explain the parameters in the query:We know that when passing parameters in SQL for query, we usually use preparedstatement to write a lot of "?" In the statement,This method can also be used in hql, for example:List mates = sess. Find ("Select employee. name from employee as employee" +"Where emp
literals 'foo', 69, '2017-01-01 10:00:01. 0'
Java public static final constants eg. color. Tabby
I don't have to explain anything else. Here I just want to explain the parameters in the query:We know that when passing parameters in SQL for query, we usually use preparedstatement to write a lot of "?" In the statement,This method can also be used in hql, for example:List mates = sess. Find ("Select employee. name from employee as employee" +"Where emp
Hive optimization tips-How to Write HQL
I. Hive join Optimization1. try to place the small table on the left of join. The hive-0.12.0 we use here is automatically converted. This means that the small table is automatically loaded into the memory and the map side join is executed (with good performance ), this is done by the hive parameter. auto. convert. join = true and hive. smalltable. filesize = 25000000L) parameter control (25 MB by default). If t
Hibernate uses hql for Chinese sorting,
Why does MySQL not support Chinese sorting? No way. You only need to wait for utf8_unicode_cn to come out. If you want to implement cross-database with hibernate and do not want to change the code, I will tell you the answer below.
Method 1. Description: register a sorting method for the MySQL dialect package of Hibernate. MySQL Chinese sorting is implemented in this method. Code:
public class MySQLExtendDialec
Paging:Before using the hibernate-encapsulated paging method, let's review the native paging practices in Oracle1 --Paging Query2 --(pageNo-1) *pagesize= start line pageno*pagesize= end line3 Select * from(4 SelectRowNum rm,s.* from(5 Select * fromMyfirsttbOrder byStuagedesc) s6 whereRowNum5) 7 whereRm>=2;8 Generally use three layer to do paging queryNow we understand how hibernate provides paging.Query object provides a method for paging queries1. Starting Line:S
Chinese issue about the hql Commander window of hibern8ide --
Long story short.
System Environment:Hibernate 2.1Hibernate-extensions-2.1.2Eclipse 3.0Ant 1.6Oracle 8.1.7
Find a directory \ hibernate-extensions-2.1.2 \ hibern8ide \ SRC \ net \ SF \ hibern8ide \ highlighter
The following editordocument. Java File
Modify row 24th
Styleconstants. setfontfamily (defaultstyle, "");
Then use ant to re-compile hibern8ide
C:/> ant jar
A new hibern8
Use DetachedCriteria to construct HQL parameter dynamic match, detachedcriteria
This article is based on Spring MVC + Spring + Hibernate platform.
1. DetachedCriteria build class: CriteriaBuilder. java
package com.ims.persistence.base;import java.math.BigDecimal;import java.sql.Types;import java.util.Map;import org.apache.commons.lang3.StringUtils;import org.hibernate.criterion.Criterion;import org.hibernate.criterion.DetachedCriteria;import org.hibe
Java_Web: Hibernate + jsp + selvect + HQL data query, java_webselvect
As the saying goes: "A good memory is worse than a bad pen ". I have been studying Hibernate for a week and have a preliminary understanding of Hibernate. Next, take a note of the Hibernate data and use the Hibernate + jsp + selvect of the rental system.
Step 1: Compile the Housing Entity
/** House entity class */public class House {private int id; // House id private String title;
1. Use the list () method to get the results of the query, issuing a statement each time to get all the data.2. Use the iterate () method to get the results of the query, first issue an SQL statement to query the ID that satisfies the condition data, and then follow these IDs to query the records, that is, to execute the N+1 SQL statement (n is the number of records that match the criteria)Two execution of the list () method, each execution is issued an SQL statement, query all data.Here's a loo
Because some of the syntax of MySQL is not supported in HQL, so after querying all kinds of information to obtainIf the sort requirement is, if the A field is sorted (the A field is stored in a string of numbers), when the A field is empty, it is the last, and the empty one is sorted with the modified time modify_date, you can writeOrder by Case when Ifnull (A,")='then0Else1 Enddesc, A+0ASCASCA+0 prevents the occurrence of 1,11,123,11234,2,3,4 whe
public void Querycustomerbymerchantid () { sessionfactory SF = hibernateutil.getsessionfactory (); Session session = Sf.getcurrentsession (); Transaction ts = session.begintransaction (); try { Query query=session.createquery ("Select C from Customer C join c.merchant m where m.mid=1"); List customer = Query.list (); for (int i=0;i public void Querycustomerbyorderid () { sessionfactory SF = hibernateutil.getsessionfactory ();
Functions:like Upper () and lower ()parentheses () indicate grouping in, between, is nullJDBC in Parameters?Named Parameters:name,: start_date,: X1 (This should be another "?" Workaround for the solution)SQL literals ' foo ', 69, ' 1970-01-01 10:00:01.0 'Java public static final constants eg. Color.tabbyOther than to explain, here I just want to query the parameters of the problem description:We know that in the SQL to carry out the parameters of the query, we usually use PreparedStatement, in
The parameters that need to be used in hql and in are indeterminate, and are implemented as follows:
listQuery query = Session.createquery ("From TestTable where Testfield in (: testfieldvalues)"); Query.setparameterlist ("Testfieldvalues", testfieldvalues); Query.list ();
Tips: You need to use the Query.setparameterlist () method instead of Query.setparameter () to set the list parameter.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.