Hql functions and hql Functions
Serial number
Function Name
Description
Type
Supported
Usage
Remarks
1
ABS (n)
Take absolute value
Mathematical functions
JPAQL HQL
ABS (column_name [numeric object attributes])
2
SQRT (n)
Take the square root
Mathematical functions
JPAQL
Hibernate hql Query:The criteria query encapsulates the query criteria in an object-oriented manner, but HQL (Hibernate query lanaguage) queries provide richer and more flexible query features. As a result, Hibernate makes the HQL query the official recommended standard Query method, HQL query to cover all the function
Software requirements include 3 different tiers-business requirements, user requirements, and functional requirements. In addition, each system also has a variety of non-functional requirements.
Business requirement represents a high-level goal for an organization or custome
hql QueryHQL query:The criteria query encapsulates the query criteria in an object-oriented manner, but HQL (Hibernate query lanaguage) queries provide richer and more flexible query features. As a result, Hibernate makes the HQL query the official recommended standard Query method, HQL query to cover all the functions
Hibernate HQL Query Statement summary1, Entity query:As for the entity query technology, we have already dealt with it many times before, such as the following example:String hql= "from user User";List list=session. CreateQuery (HQL). List ();The result of the above code execution is that all data corresponding to the user entity object is queried, and the data i
1, Entity query:As for the entity query technology, we have already dealt with it many times before, such as the following example:String hql= "from user User";List list=session. CreateQuery (HQL). List ();The result of the above code execution is that all data corresponding to the user entity object is queried, and the data is encapsulated into a user entity object and returned in the list. It is important
1, Entity query:As for the entity query technology, we have already dealt with it many times before, such as the following example:String hql= "from user User";List list=session. CreateQuery (HQL). List ();The result of the above code execution is that all data corresponding to the user entity object is queried, and the data is encapsulated into a user entity object and returned in the list. It is important
, we can write more complex queries with simple code.1 String hql = "from Emp e where e.dept.deptno=?" ; 2 Query q = session.createquery (HQL); 3 Q.setinteger (0, 10);View Code9. Join (Inner Connection, outer connection)In SQL we have inner connection, right outer connection, left outer connection, full outer connection, we also have these concepts in
= "from Emp e where e.dept.deptno=?" ; 2 2 Query q = session.createquery (HQL); 3 3 q.setinteger (0, 10);View Code9. Join (Inner Connection, outer connection)In SQL we have inner connection, right outer connection, left outer connection, full outer connection, we also have these concepts in HQL. However, there are several inconsistencies:
If there is no relationship between
First, use expression to generate query conditions using dynamic expressions,
Expression body = expression. Constant (true );
Body = expression. And (body, expression );
Then execute the query
Session. queryover
The following error is reported:
You cannot forcibly convert objects of the type "nhibloud. hql. Ast. hqlbitwiseand" to the type "nhibloud. hql. Ast. hqlbooleanexpression"
Solution:
Replace express
-4.2.1.final\project\etc\hibernate.properties.template Or Configurable property values in the Hibernate-release-4.2.1.final\project\etc\hibernate.properties file Iii. named parameters of HQLExample:/*** Use HQL according to the name Query method* @param entity*/public static void Query (String name) {Session s = null;try {S=hibernateutil.getsession ();HQL:The from behind is not the table name, but the object name (class name)String
The article summarizes, longitudinal, transverse, from the surface to the point, finally is the demand quality control.
The requirement analysis of software must have a deep understanding of the original business, extraction, abstraction, sublimation process.
Software requirements analysis is to extract from the user's business software system can help users solve the business problems, through the user's business problem analysis, the planning of
you just want to get the attributes of a class. The above SQL can be changed to the following HQL statement using the SELECT clause:
select product from Order as o inner join o.products as product
The above HQL statement returns all the products instances in the order. If you want to get a property of an object, you can write the HQL statement in the following
The previous article discussed the connection query in the HQL query, its query syntax in the function and SQL connection query is the same, the inner join query obtains the Cartesian product between the relations, the outer join query is to obtain a relational table and with another relational table of the collection part, the specific use method see the previous article, Finally, the method of the external named query is discussed. This article will
HqlHql query:Criteria queries encapsulate the query conditions in an object-oriented manner and conform to the programming mindset. However, hql (Hibernate query language) queries provide richer and more flexible query features, therefore, Hibernate sets the hql query method as the standard query method officially recommended. hql queries provide a query method s
Query LanguageHibernate Query Language (HQL) is an object-oriented query language, similar to SQL, but not to operations on tables and columns, but object-oriented and their properties. HQL queries are translated into traditional SQL queries by Hibernate to manipulate the database.Although you can use local SQL statements directly, I recommend that you use the HQL
Hql query:
Criteria queries encapsulate the query conditions in an object-oriented manner and conform to the programming mindset. However, hql (Hibernate query language) queries provide richer and more flexible query features, therefore, Hibernate sets the hql query method as the standard query method officially recommended.
1. query all fields of the entire ing object
Java code
// The direct from query shows a ing object, that is, querying all fields of the entire ing object.
String hql = "from users ";
Query query = session. createquery (hql );
List
Users = query. List ();
For (users user: Users ){
System. Out. println (user. getname () + ":" + User. getpasswd () + ":" + User. GETID ());
}
Output result
In many cases, the Data Access Layer (DAO layer) that we are responsible for usually uses SQL statements or HQL statements, and sometimes error when we use the HQL statement stitching, usually because we use standard SQL statements to open object-oriented statements that are indeed hibernate Sessionfactory.getcurrentsession (). createquery (SQL);We should change to Sessionfactory.getcurrentsession (). creat
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.