以下命名查询
<named-query name="fix.getByProblem">
<query>
SELECT f
FROM Fix f JOIN f.solved s
WHERE s.id IN :ids
</query>
</named-query>
应该返回解决至少一个给定问题的所有修复程序,但失败并显示错误消息
异常描述:编译查询时出错 [fix.getByProblem]:
SELECT f FROM Fix f JOIN f.solved s WHERE s.id IN :ids
],类 [ProblemHandle] 的未知状态或关联字段 [id]。
模型如下:(简化)
修复.java
@ElementCollection
@CollectionTable(name = "FIX_SOLVED", schema = SCHEMA_NAME, joinColumns = {@JoinColumn(name = "SOURCE_VERSION", referencedColumnName = "version")})
@AttributeOverrides({ @AttributeOverride(column = @Column(name = "SOLVED_ID", nullable = true), name = "id") })
private Collection<ProblemHandle> solved;
问题句柄.java
@Embeddable
@Access(AccessType.PROPERTY)
public class ProblemHandle {
private Long id;
...
}
问题.java
@Entity(name = Problem.ENTITY_NAME)
@Access(value = AccessType.FIELD)
@Table(name = Problem.TABLE_NAME, schema = Problem.SCHEMA_NAME)
@IdClass(ProblemHandle.class)
public class Problem {
public static final String ENTITY_NAME = "problem";
public static final String SCHEMA_NAME = "X";
public static final String TABLE_NAME = "PROBLEM";
@Id
@Column(name="id", nullable = false)
private Long id;
...
}
我怎样才能在不改变模式的情况下实现这一点,例如使用句柄?