我Car和CarType物體之間的單向關系如下:
public class Car {
@Id
private Long id;
@ManyToOne
private CarType type;
//other fields / getters / setters
}
public class CarType {
@Id
private Long id;
private String code;
//other fields / getters / setters
}
這種單向關系很好地滿足了要求。但是現在我有一個新的要求來獲取CarType給定Carid 集的 s 集。
如何在不使用本機查詢且不創建雙向關系的情況下做到這一點?
uj5u.com熱心網友回復:
這應該作業
@Query("select c.type from Car c where c.id in (:ids)")
List<CarType> findCarTypesFor(List<Long> ids)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/521159.html
