Projection投影

database

Selection means which rows are to be returned.

if the query is

select a, b, c from foobar where x=3;

then "a, b, c" is the projection part, "where x=3" the selection part.

解释二

In terms of query it is:

SELECT *PROJECTION* FROM Table

*PROJECTION* is expression for data transformation.

Example:

SELECT * FROM ORDER

In Hibernate, the Criteria equivalent would be:

List orders = session.createCriteria(Order.class).list();

No projection here, we take data without transformation. If we want one:

SELECT NAME FROM PRODUCT

Here, the Projection class comes into play. The above query can be rewritten into a Criteria query as:

List products=session.createCriteria(Product.class)

.setProjection(Projection.property("name"))

.list();

So we project all rows to single item: name field.

There are other projections: Projection.rowCount() for example (for COUNT(*))

参考资料

  1. What are projection and selection?
  2. What is a Projection in NHibernate?
  3. Hibernate 4.3.11 Final - Relational Persistence for Idiomatic Java

以上是 Projection投影 的全部内容, 来源链接: utcz.com/z/532666.html

回到顶部