2

I have two entities

@Entity
@Table(name="one")
public class One implements Serializable {
  @Id
    @NotNull
    @Column(name = "id")
    private String id;

     @Column(name = "name")
    private String name;

    @Column(name = "title")
    private String title;

    @ManyToOne
    @JoinColumn(name = "three_id")
    private Three three;
}

@Entity
@Table(name="two")
public class Two implements Serializable {
    @Id
    @NotNull
    @Column(name = "id")
    private String id;

     @Column(name = "order")
    private String order;

    @ManyToOne
    @JoinColumn(name = "three_id")
    private Three three;
}

@Entity
@Table(name="three")
public class Three implements Serializable {
  @Id
    @NotNull
    @Column(name = "id")
    private String id;

     @Column(name = "quantity")
    private String quantity;
}

And a named query as select o.name from one o, two tw, three th where tw.order="test" and o.three.id = tw.three.id;

Jboss throws following error when deploying this org.hibernate.HibernateException: Errors in named queries

The intention is I want rows from two tables based on the common column three_id which is the id field in table "three" Why is it failing and how can I fix this.

Annapoorni D
  • 831
  • 2
  • 13
  • 30

1 Answers1

0

Well, it seems that you are not using three th anywhere in the query, it might be the problem.

This should work:

select o.name from one o, two tw where tw.order="test" and o.three.id = tw.three.id;

Milan
  • 1,780
  • 1
  • 16
  • 29