Hello,
I am facing a strange issue while executing the query in Hibernate 4.3.7. I am using Spring 4.1 and Hibernate implementation of JPA.
Below is the mapping
@Entity @Table(name="A") public class A { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="A_ID") private Integer aId; @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="B_ID") @Fetch(FetchMode.JOIN) private B b; @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="C_ID") private C c; @Column(name="CITY") private String city; }
@Entity @Table(name="B") public class B { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="B_ID") private Integer bId; @ManyToOne(cascade = CascadeType.ALL,fetch=FetchType.EAGER) @JoinColumn(name="D_ID") @Fetch(FetchMode.JOIN) private D d; @Column(name="DISPLAY") private String displayInd;
}
@Entity @Table(name="C") public class C { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="C_ID") private Integer cId; @Column(name="NAME") private String name;
}
@Entity @Table(name="D") public class D { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="D_ID") private Integer dId; @Column(name="ADDRESS") private String address;
}
Below is the query SELECT a.city,b.displayInd,b.d.address,c.name from A a LEFT JOIN a.b b LEFT JOIN c.c c
Problem Statement - So if i execute above it gives bad sql grammar exeception. However, if i remove b.d.address field the query executes properly. Kindly Suggest
SELECT a.city,b.displayInd,b.d.address,c.name from A a LEFT JOIN a.b b LEFT JOIN c.c c....this query works fine with hibernate 3.6
|