标签:import ota ble ber 问题 size ffd query 根据
一的一方:AppVsStaff.java
AppVsStaff中包含两个多的一方,Applications.java和StaffDict.java
import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; @Entity @Table(name = "APP_VS_STAFF") public class AppVsStaff { @Id @Column(name="APP_VS_EMP_ID") @NotNull(message = "应用程序人员关系ID不能为空") @Size(min = 1,max = 20,message = "应用程序人员关系ID不能超过20字且不能为空") private String AppVsEmpId; @JoinColumn(name = "APP_ID") @ManyToOne @NotFound(action = NotFoundAction.IGNORE) private Applications applications; @JoinColumn(name = "EMP_ID") @ManyToOne @NotFound(action = NotFoundAction.IGNORE) private StaffDict staffDict; @Column(name="CAPABILITY") private String capability; }
问题:要根据StaffDict中的某个属性查出Applications对应的list
解决如下:
List<Applications> appList = new ArrayList<>(); String jpql = "SELECT app FROM AppVsStaff appVsStaff LEFT JOIN appVsStaff.applications app WHERE appVsStaff.staffDict.userName=:userName"; appList = entityManager.createQuery(jpql).setParameter("userName", userName).getResultList();
标签:import ota ble ber 问题 size ffd query 根据
原文地址:http://www.cnblogs.com/ms-grf/p/7678073.html