1. Object Query:The object query technology has already been involved many times before, for example, the following example:String hql = "from user ";List list = session. createquery (hql). List ();The code above is executed to query all the data corresponding to the user object, encapsulate the data into the user object, and put it in the list to return. It should be noted that there is a judgment on the i
The three major frameworks of Java_Web: the foundation of Hibernate + HQL, java_webhql
12.1 HQL language basicsThe Hibernate Query Language is HQL (Hibernate Query Language). You can directly use the object class name and attributes. The HQL syntax is similar to SQL, and has SQL keywords such as select, from, order by,
Hql:hibernate Query Language.
Characteristics:
>> 1, similar to SQL, the syntax in SQL is basically straightforward to use.
>> 2,sql queries are columns in tables and tables, and HQL queries are objects and properties in objects.
>> 3,hql keywords are case-insensitive, and the class name and property name are case-sensitive.
>> 4,select can be omitted.
1, simple query, employee is entity name
Hibernate (9) HQL query and hibernatehql QueryI. query methods provided by Hibernate
OID query method: Primary Key query. The get () or load () method is used to load the specified OID object and the query result is
HQL Query method: Query using the HQL language through the Query interface
QBC query method: queries by using interfaces and classes such as Crit
The criteria query encapsulates the query criteria in an object-oriented manner, but HQL (Hibernate query Language) 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 of the criteria query, provides a similar standard SQL statement
I. Introduction of HQLHQL (Hibernate query Language) is an object-oriented query language that relies on the query class, each of which corresponds to a querying object. The query steps are as follows:1) Get Hibernate Session Object2) Writing HQL statements3) Call the session's CreateQuery () method to create a query condition with the HQL statement as the argument4) If the
First, let's take a look at several retrieval methods provided by hibernate:
1. navigation object graph Retrieval Method: navigate to other objects based on the loaded objects. For example, for a loaded customer object, call its getorders (). the iterator () method can be used to navigate to all associated order objects. If a delayed loading search policy is used at the association level, hibernate loads the associated order object from the database. Otherwise, it retrieves the order object from
First, Hibernate provides the Query method
OID Query method: Primary key query. An object that loads the specified OID through the get () or load () method results in a
Hql Query method: query interface using the HQL language
QBC Query method: Through the criteria and other interfaces and classes are query
Local SQL Query method: Query using native SQL language
Object Navigation Que
Hibernate Run Process:Hibernate role 1, Hibernate is a bridge between Java applications and relational databases, and she is responsible for mapping between Java objects and relational databases. 2. Hibernate internally encapsulates the operation of accessing the database through JDBC, providing an object-oriented data access API to upper-level applications. Hibernate API Introduction 1. Providing access to database operations (Session,transaction,query) 2. Configure Hibernate interf
Hibernate provides a powerful query system. You can use Hibernate's HQL query, conditional query, or even native SQL query statements. The powerful query statements configured by Hibernate during HQL query. HQL is consciously designed to be fully object-oriented queries. It can understand concepts such as inheritance, polymorphism, and association.1.
Hibernate Retrieval Method
1:hibernate provides the following ways to retrieve objects 1, the navigation object graph retrieval Method: Obtains the persistent entity object in the program, through the object Association, obtains the related entity object. For example: Session.get (department.class,1); Dept.getemps () 2, OID retrieval method: The session of Get or load based on the OID to find object 3, hql retrieval mode: query interface. Query by
Hibernate HQL and hibernatehql1. Hibernate HQL explanation 1.1. hql Introduction
Hibernate is equipped with a very powerful Query Language, which looks like SQL. But no
To be confused by syntax-structure similarity, HQL is designed to be fully Object-oriented for queries.
It can understand concepts such as inheritance,
Introduction: Why this demand, from the company's project needs, the company's projects using Java struts2+spring2.5+oracle Middleware tuxedo, database with Oracle, but because not directly connected to the database, with the middleware processing way, And do not want to have too much service, so began to network to find data collation coding. It took about one weeks to complete the task, and now it's all sorted out to share with you. 1. need to import the relevant jar Package : [ alphabetical
HQL is Hibernate query language that is hibernate querying language1. The steps to execute the HQL statement:(1), Get Session objectConfiguration cfg = new configuration ();sessionfactory sessionfactory = Cfg.buildsessionfactory ();Session session = Sessionfactory.getcurrentsession ();(2), write HQL statement(3), create querysession.createquery (
HQL and SQL differencesThe difference between 1.HQL and SQLSQL database Table query HQL Object-oriented queryHql:from followed by the class name + class object where you use the properties of the object to do the condition Sql:from followed by the table name where to use the table field to make the conditional queryWhen you use queries in Hibernate, you typically
I accidentally found a very interesting hql usage and shared it with me.
Example:
1. Student database table (MySQL)
CREATE TABLE `student` ( `ID` int(11) NOT NULL, `NAMES` varchar(50) NOT NULL, `AGE` int(3) NOT NULL, PRIMARY KEY (`ID`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Table Data
ID
Names
Age
1
Wang Peng
24
2
Zhang San
12
2. Student object class
@Entity@Table(name = "STUDENT")public class Stude
Excerpt from someone, more useful, more comprehensive.//hql:hibernate Query Language.//Features://>> 1, similar to SQL, the syntax in SQL is basically straightforward to use. //>> 2,sql queries are columns in tables and tables, and HQL queries are objects and properties in objects. //>> 3,hql Keywords are case-insensitive, and the class name and property name are case-sensitive. //>> 4,select can be omitted
HQL (Hibernate Query Language). The traditional SQL language uses structured query methods, which can do little to the data that exists in the form of objects. To do this, Hibernate provides us with a syntax-like SQL language, which is HQL (Hibernate query language), unlike SQL, HQL is an object-oriented query language that can query data that exists as an object
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.