The follwing named query
<named-query name="fix.getByProblem">
<query>
SELECT f
FROM Fix f JOIN f.solved s
WHERE s.id IN :ids
</query>
</named-query>
is supposed to return all fixes that solve at least one of the given problems, but fails with the error message
Exception Description: Error compiling the query [fix.getByProblem]:
SELECT f FROM Fix f JOIN f.solved s WHERE s.id IN :ids
], unknown state or association field [id] of class [ProblemHandle].
The model is as follows: (simplified)
Fix.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;
ProblemHandle.java
@Embeddable
@Access(AccessType.PROPERTY)
public class ProblemHandle {
private Long id;
...
}
Problem.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;
...
}
How can I achieve that without having to change the pattern, e.g. using handles?