HQL查询语句
本文为博主原创,允许转载,但请声明原文地址:http://www.coselding.cn/blog/8/8-142.html HQL语法结构类SQL语句, Query query = session.createQuery(String HQL); 通过一个HQL查询语句得到一个Query的对象,可以通过这个对象得到HQL语句的查询结果集 查
本文为博主原创,允许转载,但请声明原文地址:http://www.coselding.cn/blog/8/8-142.html
- HQL语法结构类似SQL语句,
- Query query = session.createQuery(String HQL); 通过一个HQL查询语句得到一个Query的对象,可以通过这个对象得到HQL语句的查询结果集
- 查询支持内链接,左右外连接,支持对Hibernate实体类的直接查询,以及对A实体类中的其他B实体类成员直接用”.”来作为A实体类的列来调用(已设置关联关系);
- From,select,where,order by,group by,子查询都和SQL一样,具体查询文档
- ?序号是从0位开始的
- Query.list的数据用完才能session.close()
- Query支持正常的SQL、HQL、EJBQL。功能强弱:NativeSQL>HQL>EJBQL>QBC>QBE。
- HQL占位符:”:参数名”或者”?”,使用setInteger等方法直接替换占位符中的参数。
- 分页:setMaxResults:设置每页条数,setFirstResult设置从第几条开始。
- 可以像SQL一样返回每个列的属性值,每个属性值以Object返回,形成一个Object数组。也可以把这些返回的列值合成一个临时的包装对象进行保存,在HQL写”new 类限定名”。
- HQL用”join”进行导航连接,join t.topic不能用join Topic,因为要设定t中的哪个对象和Topic进行连接。
- query.uniqueResult():返回查询唯一对象。
- count(*)返回long类型,用query.uniqueResult()。
- 聚合函数、between…and、in、not null、is empty、is not empty、like、exists、not exists。Exists的执行效率比in高。
- EJBQL常用函数,变大小写、连接字符串、去空格、平均数、求和等函数。(不重要)
- 日期直接用>、
- group by、having、子查询、ALL函数。
- NameQuery:将查询命名起来,之后直接用key调用,@NameQueries定义命名查询,将查询语句集中化管理。
- createSQLQuery():使用正常的SQL语句查询,返回SQLQuery,@NameNativeQueries。
- QBC(Query By Criterial):Criteria约束集合,用Restrictions产生查询约束条件,即where后面的子句,相当于把SQL语句变得面向对象化!!!DetachedCriteria:创建好再绑定session的对象,可以脱离session管理。
- QBE(Query By Example):Example e = Example.create(Object obj);产生一个约束条件对象,可以当作Criteria的约束对象加入进去,使面向对象更彻底。
本文为博主原创,允许转载,但请声明原文地址:http://www.coselding.cn/blog/8/8-142.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Download the latest version of 12306 ticket booking app. It is a travel ticket purchasing software that everyone is very satisfied with. It is very convenient to go wherever you want. There are many ticket sources provided in the software. You only need to pass real-name authentication to purchase tickets online. All users You can easily buy travel tickets and air tickets and enjoy different discounts. You can also start booking reservations in advance to grab tickets. You can book hotels or special car transfers. With it, you can go where you want to go and buy tickets with one click. Traveling is simpler and more convenient, making everyone's travel experience more comfortable. Now the editor details it online Provides 12306 users with a way to view historical ticket purchase records. 1. Open Railway 12306, click My in the lower right corner, and click My Order 2. Click Paid on the order page. 3. On the paid page

How to check my academic qualifications on Xuexin.com? You can check your academic qualifications on Xuexin.com, but many users don’t know how to check their academic qualifications on Xuexin.com. Next, the editor brings you a graphic tutorial on how to check your academic qualifications on Xuexin.com. Interested users come and take a look! Xuexin.com usage tutorial: How to check your academic qualifications on Xuexin.com 1. Xuexin.com entrance: https://www.chsi.com.cn/ 2. Website query: Step 1: Click on the Xuexin.com address above to enter the homepage Click [Education Query]; Step 2: On the latest webpage, click [Query] as shown by the arrow in the figure below; Step 3: Then click [Login Academic Credit File] on the new page; Step 4: On the login page Enter the information and click [Login];

MySQL and PL/SQL are two different database management systems, representing the characteristics of relational databases and procedural languages respectively. This article will compare the similarities and differences between MySQL and PL/SQL, with specific code examples to illustrate. MySQL is a popular relational database management system that uses Structured Query Language (SQL) to manage and operate databases. PL/SQL is a procedural language unique to Oracle database and is used to write database objects such as stored procedures, triggers and functions. same

If you want to check the activation date using an Apple mobile phone, the best way is to check it through the serial number in the mobile phone. You can also check it by visiting Apple's official website, connecting it to a computer, and downloading third-party software to check it. How to check the activation date of Apple mobile phone Answer: Serial number query, Apple official website query, computer query, third-party software query 1. The best way for users is to know the serial number of their mobile phone. You can see the serial number by opening Settings, General, About This Machine. . 2. Using the serial number, you can not only know the activation date of your mobile phone, but also check the mobile phone version, mobile phone origin, mobile phone factory date, etc. 3. Users visit Apple's official website to find technical support, find the service and repair column at the bottom of the page, and check the iPhone activation information there. 4. User

Title: How to use Oracle to query whether a table is locked? In Oracle database, table lock means that when a transaction is performing a write operation on the table, other transactions will be blocked when they want to perform write operations on the table or make structural changes to the table (such as adding columns, deleting rows, etc.). In the actual development process, we often need to query whether the table is locked in order to better troubleshoot and deal with related problems. This article will introduce how to use Oracle statements to query whether a table is locked, and give specific code examples. To check whether the table is locked, we

Forum is one of the most common website forms on the Internet. It provides users with a platform to share information, exchange and discuss. Discuz is a commonly used forum program, and I believe many webmasters are already very familiar with it. During the development and management of the Discuz forum, it is often necessary to query the data in the database for analysis or processing. In this article, we will share some tips for querying the location of the Discuz database and provide specific code examples. First, we need to understand the database structure of Discuz

How to check the latest price of Tongshen Coin? Token is a digital currency that can be used to purchase in-game items, services, and assets. It is decentralized, meaning it is not controlled by governments or financial institutions. Transactions of Tongshen Coin are conducted on the blockchain, which is a distributed ledger that records the information of all Tongshen Coin transactions. To check the latest price of Token, you can use the following steps: Choose a reliable price check website or app. Some commonly used price query websites include: CoinMarketCap: https://coinmarketcap.com/Coindesk: https://www.coindesk.com/ Binance: https://www.bin
