简体   繁体   English

JPA:如何编写查询功能

[英]JPA : How to write query function

I know from sample code how to write one query function like findAll(): 我从示例代码中知道如何编写一个查询函数,例如findAll():

        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
    cq.select(cq.from(entityClass));
    return getEntityManager().createQuery(cq).getResultList();

But can i ask how to write query based on the where condition like name should bigger than 18, and i also confuse that how to write query based on left join right join or inner join? 但是我可以问一下如何根据条件(如名称)应大于18来编写查询,并且我也混淆了如何根据左连接,右连接或内部连接来编写查询吗?

Note that all the query return List result, my current way to do that is get result, and manipulate the List( like eliminate the element in the List, or combine two list) 请注意,所有查询都返回List结果,我目前的做法是获取结果,并操作List(例如消除List中的元素,或合并两个列表)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM