HQL用起来相当简单。
Listing 7. HQL query in a find method call.
清单7.find方法调用中的HQL查询。
Listing 14. HQL query in a find method call.
清单14.find方法调用中的HQL查询。
But our supporting example will use HQL exclusively.
但是我们使用的示例只用HQL。
But HQL does enable you to pass native queries to your underlying database.
但HQL的确可以让你直接向底层数据库传递本地查询。
For information on externalizing HQL queries, refer to the Resources section.
有关外化HQL查询的更多信息,参阅参考资料部分。
If your HQL or Criteria returns a lot of data, you should take care of two things.
如果你的HQL或Criteria会返回很多数据,那么要注意两件事。
As of now, sharding framework cannot be used with HQL. It can only be used with SQL.
到目前为止,分片框架不能用于HQL,它只能用于SQL。
From the WHERE clause in HQL you can usually guess the corresponding SQL WHERE clause.
从HQL的WHERE子句中通常可以猜到相应的SQL WHERE子句。
Listing 17 illustrates a way to retrieve the entire database using a two-word HQL query.
清单17显示了一种使用两个词的HQL查询来检索整个数据库的方法。
SQL queries are exposed through the same Query interface, just like ordinary HQL queries.
和普通的HQL查询一样,SQL查询同样是从Query接口开始的。
With Hibernate, you can define an HQL query in a Hibernate mapping file (hbm.xml) and give it a name.
使用Hibernate,可以在Hibernate映射文件(hbm . xml)中定义HQL查询并为其命名。
Note that this might result in several immediate selects being used to execute a particular HQL query.
注意这可能意味着在一条HQL查询后紧跟着一系列的查询。
If you can't redesign your legacy table, you can use projection provided in HQL or Criteria to retrieve data.
如果不能重新设计遗留表,可以使用HQL或Criteria提供的投影功能来获取数据。
To access an Individual from the database, simply specify the class name in your HQL query, as shown in Listing 5.
要想访问数据库中的Individual,只需在HQL查询中指定类名即可,如清单5所示。
Named SQL queries may be defined in the mapping document and called in exactly the same way as a named HQL query.
可以在映射文档中定义SQL查询的名字,然后就可以像调用一个命名HQL查询一样直接调用命名SQL查询。
Amongst all the retrieved table columns returned from the HQL query, an extra dynamic column will be returned as well.
在HQL查询返回的检索到的所有表的列中,还会返回一个额外的dynamic列。
Of course, not many of us would need (or want, for that matter) to retrieve the entire database with a single HQL query.
当然,我们之中没有多少人需要只用一个HQL查询检索整个数据库。
The only exception is when your application has special business rules for data aggregation and ordering that HQL doesn’t support.
当你的应用程序对数据聚合和排序有HQL不支持的特定业务规则时除外。
You can build a HQL WHERE clause using either binding parameters or simple string concatenation; the decision impacts on performance.
既可以使用绑定参数构造HQL的WHERE子句,也可以使用字符串拼接的方法,该决定对性能会有一定影响。
The Hibernate Query Language (HQL), designed as a minimal object-oriented extension to SQL, is an elegant bridge between the object and relational worlds.
Hibernate查询语言(HQL)被设计成SQL 的一个微型面向对象扩展,它是对象和关系世界之间的桥梁。
And, since our two mapped classes (Building and Land) inherit from Estate, we can use this abstract superclass in our HQL queries, as shown in Listing 14.
而且,因为两个映射的类(Building和Land)是从estate中继承而来,所以我们可以在HQL查询中使用这个抽象超类,如清单14所示。
HQL supports the use of ANSI SQL row value constructor syntax (sometimes called tuple syntax), even though the underlying database may not support that notion.
HQL支持ANSISQL行值构造语法的用法,(有时叫元组语法),甚至虽然底层数据不支持这种语法。
Hibernate allows you to define a fetching strategy at two locations. One is to declare it in the mapping metadata; the other is to override it in either the HQL or the Criteria.
Hibernate允许在两个地方定义数据抓取策略,一处是在映射元数据中,另一处是在HQL或Criteria中覆盖它。
Hibernate allows you to define a fetching strategy at two locations. One is to declare it in the mapping metadata; the other is to override it in either the HQL or the Criteria.
Hibernate允许在两个地方定义数据抓取策略,一处是在映射元数据中,另一处是在HQL或Criteria中覆盖它。
应用推荐