As a veteran ORM framework, Hibernate's contribution to the database persistence layer is a visible achievement.It provides more and more data query methods, from SQL to self-created HQL to object-oriented standardized queries.Although the query is a bit confusing, the configuration is a bit more complicated to use.But there's no way to hide its fascinating place, this blog tries to summarize all of Hibernate's queries.Radish green vegetables each the
Hibernate query method (HQL/QBC/QBE) Summary, hqlqbc
As an old ORM framework, Hibernate has made significant contributions to promoting the database persistence layer.
It provides more and more data query methods, from SQL to self-built HQL, To object-oriented standardized query.
Although the query method is a little dazzling, the configuration is a little complicated to use.
But it cannot cover up its char
The Hibernate framework provides HQL queries and criteria queries. Here is an example of these two queries. There is a general understanding of these two query methods. Use the Housing Information table as an example to check all housing information.HQL Statement Query all housing information:/** Check All houses * * (non-javadoc) * @see dao.housedao#selecthouse ()*/ PublicListSelecthouse () {//TODO auto-generated Method Stub//Get ConnectionsSessi
What is the difference between HQL query and Criteria query in The Hibernate framework? hibernatehql
The Hibernate framework provides HQL query and Criteria query. The following is an example of the two types of queries. Or have a rough understanding of these two query methods. The housing information table is used as an example to query information about all houses.
The
Solutions that need to add multiple query criteria after two tables are federatedOne, this is my first time in the project team to do financial leasing problems encountered, the code is as follows:Public Composedbean overduereminder (Map param) throws commonexception{Composedbean Composedbean = new Composedbean ();StringBuffer sql = new StringBuffer ();Sql.append ("SELECT * FROM (")0 application number, 1 applicant type. Append ("Select M.asqbh,m.asql
HQL First Class:Hibernate query Language:hibernate querying language Grammar:QueryString hql= "from dept";Query query=session.createquery (HQL);//Return list collectionQuery is a list collectionHQL statement Next note detailed, this production simple operation! 1 Public StaticListgetdept () {2ListNewArraylist();3Configuration conf=NULL;4Sessionfactory fa
HQL (Hibernate query Language) is an object-oriented query language that is very similar to SQL. In Hibernate, HQL is the most widely used method of retrieval.Has the following frequently used functions:(1) In the query statement, can set various conditions(2) Support checking out the object part of the property, is not in the SQL statement *, but query the object we want to query(3) Support connection quer
The session is the basis of the persistence layer operation, equivalent to the connection in JDBC, which saves, updates, and finds data through session sessions.Session is the center of Hibernate operation, object life cycle, transaction management, database access are related to the sessionSession created by Sessionfactory is a thread-safe thread-safe that allows multiple threads to access sessionfactory at the same timeand there's no data sharing problem.Explanation of Session in Hibernate: ht
/** * Paging query/Public List pagequery (Userinfo Userinfo) {String hql= ' select u from Userinfo u where 1=1 '; final List Paraml ist = new ArrayList (); if (Userinfo.getuserid ()!=null) {hql+= "and u.userid>?"; Paramlist.add (Userinfo.getuserid ()); } if (Userinfo.getusername ()!=null! "". Equals (Userinfo.getusername (). Trim ())) {hql+= "and username like?";
hive installation deployment, there are many tutorials on the web, I will not repeat here, this time I would like to talk about how hive submits the HQL statement to hive execution. There are several ways: first, hiveserver provide thrift interface by building Hiveserver to receive HQL statement execution from remote commit. The benefit of this is that there is no need for a hive client to simplify deplo
I. background
In work, the database used is MySQL, the project uses Java, and the JPA technology is used. Hibernate is used at the underlying layer. Some projects need to perform bitwise AND operations, but the hql language does not support it. This article describes how to enable our program to support bitwise AND operations.
II. Implementation
Preferred sqlfunction interface implementation
Package com. xxxx.
Problem description: If the parameter in the hql statement is Chinese, it is garbled after execution.
Solution: add the following statement to hibernate. cfg. xml:
In this way, the input parameters are garbled.
This solves the problem of Chinese garbled characters in the hql statement. However, if you use the hibernate update method, an error is returned.
Cause: the property of hibernate. query.
Hql syntax structure (the update/delete clause is a new feature introduced by hibernate3)[Select/update/delete][From...][Where...][Group by... [having...][Order by...]
Hql = "select distinct user. Admin from user as user ";Distinct indicates removing duplicate values.This keyword is available when the product and module fields are added in the Add Table of testcase.Hql = "select count (*) from user ";
Session session = This.getsession ();
String hql = "from Tblfwxx FW where fw.title like?";
Query query = session.createquery (HQL);
Query.setstring (0, "% brilliant Son");
Use the above. "As placeholders, and then set the values of the parameters one by one using the SetString method of query. However, this reduces the readability of the code.
So try to use "named parameter query" to solve these problem
Tags: style color io os ar java SP on CTIThe following method can convert HQL to SQL, so as to make it possible to add SQL statements with special query conditions to SQL constructs that can only be implemented with hibernate, in the case of the overall system being queried with hibernate. Protected string Hqltosql (String hql,Org.hibernate.SessionFactory sessionfactory) throws Exception {Org.hibernate.hql.
Tags: required str Let call oriented nbsp Data size Date1, HQL is Object-oriented query, case sensitive;SQL is a database-oriented query that is not case sensitive, with the Contract keyword capitalized.2, HQL syntax structure: from + Class name + Class object + where + Class object property conditions;Syntax structure of sql: from + database table name + where + table field condition.3, added :
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.