0
我有兩個實體:如何從衆多獲取對象一個關係,通過一些財產
@Entity
public class FuturePlan {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int fpId;
private String about;
private Date travelDate;
@ManyToOne(fetch=FetchType.LAZY)
private User user;
@ManyToOne(fetch=FetchType.LAZY)
private Location location;
....contructors and get/set
...和
@Entity
public class Location {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int lId;
private String lName;
....contructors and get/set
如何到location.name == "Something"
得到所有futurePlan
實例?
我正在做一個服務層。 –
你是否必須使用HQL,SQL或更具體的東西? –
標準將是最好的解決方案。但另一個解決方案也會很好。 –