我有一个看起来像这样的 Hibernate 映射:
class A {
private Long id;
private Map<C,String> someMap;
...
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ElementCollection(targetClass=String.class, fetch=FetchType.EAGER)
public Map<C, String> getSomeMap() {
return someMap;
}
pubic void setSomeMap(Map<C,String> someMap){
this.someMap = someMap;
}
}
class B {
private Long id;
private A a;
...
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToOne
public A getA(){
return a;
}
public void setA(A a){
this.a = a;
}
}
class C {
private Long id;
...
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
如何进行查询(使用标准)以获取所有具有此类“A”的“В”,例如,“test”作为“someMap”中的值?或者我只能用清晰的sql来做吗?