0

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?

Community
  • 1
  • 1
  • Do you have any other fields than `id` in `ProblemHandle` class? – Oleksandr Bondarenko Aug 26 '12 at 18:21
  • Try marking @Transient over id FIELD in ProblemHandle. – d1e Aug 27 '12 at 06:42
  • Thanks for your responses. ProblemHandle does not have any other fields, but two private constants. I tried @Transient, but it didn't have any effect. What was your thought behind this? – user1346605 Aug 27 '12 at 07:25
  • If you comment out this row: `@AttributeOverrides({ @AttributeOverride(column = @Column(name = "SOLVED_ID", nullable = true), name = "id") })` then it works. – Oleksandr Bondarenko Aug 27 '12 at 08:15
  • That does not change the situation either :-/ – user1346605 Aug 27 '12 at 08:47
  • Have you tried creating a seperate id class for Problem instead of reusing the same class used within an element collection? If it works, try a nightly EclipseLink build and file a bug if it still reproduces. – Chris Aug 28 '12 at 13:42

1 Answers1

0

You have @Access(AccessType.PROPERTY), so the name of your attribute comes from your get method, not the variable. What is the name of your get method?

Try removing @Access(AccessType.PROPERTY)

Also, what version are you using? Try using the 2.4 release.

James
  • 17,965
  • 11
  • 91
  • 146
  • I've already tried removing it as well as setting it to AccessType.FIELD (which is the default, I think), but it has no effect. The getter is called getId() and does not have any further annotations. I'm using EclipseLink 2.3, but unfortunately I cannot switch to 2.4 at the moment. I've heard that with 2.4, object comparison should be possible, so it might work with "WHERE :ids MEMBER OF s"? – user1346605 Aug 28 '12 at 08:31