Hibernate is primarily a framework for interacting with databases, and you want to manipulate relational databases in an object-oriented language, as in the next two ways:HQL Statement : Object-oriented Query language, object names are case-sensitive. And unlike SQL, this is where the object is queried, not the table, and polymorphism is supported. HQL mainly through the query operationCriteria Class : is an object-oriented query, the main query crite
Use hql to query databases:Perform the following steps:
1. Obtain the query object
//1获取query对象 String hql="FROM Employee e where e.salary>?"; Query query=session.createQuery(hql);
2. Bind a parameter (you can bind a location parameter or a name parameter (but it must start with:) or an object parameter)
Location parameters:
//2绑定
I have long known that myeclipse provides a hql editor for hibernate, which has been used before. However, when I used it today, I suddenly couldn't remember it. I found it for half a day, in my opinion, the control mode adopted by eclispe makes the user interfaces of many tools inconsistent, resulting in the user's inhabits when using a certain control.
Location of the myeclipse hql Editor:
Right-cl
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
Project development-Axure prototype Requirements Analysis and axure prototype Requirements Analysis
Introduction:
We are used to independent software development by one person, and everyone uses their own style for programming. But as the project grows or the time requirement is tight, several people are needed, A tough question for a dozen or even hundreds of people to collaborate in software development a
[Translation] basic requirements of front-end developers and basic requirements of front-end developers
Note: The title of the first translation technical article has been entangled for a long time and I don't know how to translate it. If I find that the translation is inappropriate, click the github link to submit a comment, thx ~
I wrote a README document for a project a few days ago. I hope other develop
In hql, you cannot write count (1) or count (. id. haiyisoft. vo. entity. cc. repo. businessStat (r. paramName, t. paramName, + (selectnvl (count (1), 0) + fromcom. haiyisoft. entity. cc. busi. businessb, com. haiyisoft. enti
In hql, you cannot write count (1) or count (. id) write the specific attribute String hql = select new com. haiyisoft. vo. entity. cc. rep
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.