I need to join a table and a view in a JPA query. The query won't compile because the view columns can't be identified.
Any suggestions are greatly appreciated.
Updated with parent entity and consistent naming
The query is:
select count(m.id) 
    from MultiSpeedMotor m, 
        MultiSpeedQuery q1  
    where m.id = q1.motorId 
        and q1.power = 10 
The errors are:
The state field path 'q1.motorId' cannot be resolved to a valid type.
The state field path 'q1.power' cannot be resolved to a valid type.
I am working with a legacy database that has a denormalized table similar to this
Long motorId 
Long id  
Double hi_power 
Double lo_power 
I have used a view with a union query to normalize this table into
Long motorId  
Long id 
Long hi 
Double power 
To model the view of union query in JPA, I have used an @IdClass
public class MultiSpeedQueryId implements Serializable {
    private static final long serialVersionUID = -7996931190943239257L;
    private Long motorId;
    private Long id;
    private Long hi;
    ...
}
@Entity
@Table(name = "multi_speed_query")
@IdClass(MultiSpeedQueryId.class)
public class MultiSpeedQuery implements IMultiSpeedQuery {
    @Id
    @Column(name = "motor_id")
    private Long motorId;
    @Id
    private Long id;
    @Id
    private Long hi;
    private Double power;
    ...
}
The parent Entity is mapped as:
@Entity
@Table(name = "multi_speed_motor")
public class MultiSpeedMotor implements Serializable, IMultiSpeedMotor {
    private static final long serialVersionUID = 3019928176257499187L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    ...
}
