我对 java ee 和持久性技术很陌生。我正在尝试编写一个动态查询。细节:
有一个数据表(' newsactivites '),它看起来像这样:
id type
4 UploadVideo
4 CreateBlog
1 UploadPicture
10 UploadVideo
10 CreateBlog
此外还有一个枚举:
public enum Type {
UploadVideo("show.uploadedVideo"),
UploadPicture("show.uploadedPicture"),
CreateBlog("show.createdBlog");
}
所以我想写一个这样的方法:
private List<Type> activities=new ArrayList<Type>();
@CollectionElements()
@Column(name="type")
@Enumerated(EnumType.STRING)
@JoinTable(name = "newsactivities", joinColumns = { @JoinColumn(name = "id") })
public List<Type> getActivities() {
return activities;
}
但我想在给定时间只回馈一个 id 的活动:
public List<Type> getActivities(int id) { }
任何帮助将不胜感激!