-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate 4.1.3 Left Joins
PostPosted: Wed Feb 25, 2015 9:01 am 
Newbie

Joined: Wed Feb 25, 2015 9:00 am
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: Hibernate 4.1.3 Left Joins
PostPosted: Fri Feb 27, 2015 6:14 am 
Newbie

Joined: Wed Feb 25, 2015 9:00 am
Posts: 2
Any thoughts on this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.