i have two Entity objects
object 1
@Entity
MyInfo
String key;
String eMail;
String status;
@OneToMany(mappedBy="myInfo")
private List<MyInfoRequest> myInfoRequests;
object 2
@Entity
MyInfoRequest
String key;
String dataA;
String dataB;
String dataC;
@ManyToOne
@JoinColumn(name="KEY")
MyInfo myInfo;
i try to createQuery (JPQL) with EntityManager
that wil give me all MyInfo with status="1" and myInfoRequest.dataA="BIG" but what i get is all myInfoRequest.dataA="BIG" and MyInfo with same info (i get the result as MyInfo object list of course)
this what i try
SELECT x from MyInfo x,MyInfoRequest b where b.dataA=:dataA AND x.status=:status
Im using jpa 1.0. and OpenJPA 1.2.1
Try the following query:
...
String qlString = "SELECT x "
+ "FROM MyInfo x JOIN x.myInfoRequests b "
+ "WHERE x.status = :status AND b.dataA = :dataA";
List<MyInfo> result = em.createQuery(qlString)
.setParameter("status", "1")
.setParameter("dataA", "BIG")
.getResultList();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.