大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说Projection投影「终于解决」,希望您对编程的造诣更进一步.
Selection means which rows are to be returned.
if the query is
select a, b, c from foobar where x=3;
代码100分
then “a, b, c” is the projection part, “where x=3” the selection part.
解释二
In terms of query it is:
代码100分SELECT *PROJECTION* FROM Table
*PROJECTION*
is expression for data transformation.
Example:
SELECT * FROM ORDER
In Hibernate, the Criteria equivalent would be:
代码100分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(*)
)
参考资料
- What are projection and selection?
- What is a Projection in NHibernate?
- Hibernate 4.3.11 Final – Relational Persistence for Idiomatic Java
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/9535.html