]
Lucas Villela Neder Issa commented on HHH-4795:
-----------------------------------------------
We are facing the same problem.
Comparing OneToOne mappedBy column to null generates wrong SQL
--------------------------------------------------------------
Key: HHH-4795
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4795
Project: Hibernate Core
Issue Type: Bug
Environment: Hibernate core 3.3.2.GA
Postgresql 8.4
Reporter: Uros Majeric
I have two entities:
@Entity
@Table(name = "beer_keg")
public class Keg implements Serializable {
@Id
@GeneratedValue
@Column(name = "bkid")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToOne(mappedBy="keg", fetch=FetchType.LAZY, optional=true)
public KegValveCombination getCombination() {
return combination;
}
void setCombination(KegValveCombination combination) {
this.combination = combination;
}
}
and
@Entity
@Table(name="keg_valve_combination")
public class KegValveCombination implements Serializable {
@Id
@GeneratedValue
@Column(name="id", nullable=false)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="keg", nullable=false, unique=true)
public Keg getKeg() {
return keg;
}
public void setKeg(Keg keg) {
this.keg = keg;
}
}
if I create query:
em.createQuery("FROM Keg k WHERE k.combination is null").getResultList();
hibernate generates sql like:
select keg0_.* from beer_keg keg0_ where keg0_.bkid is null
but it should be:
select keg0_.* from beer_keg keg0_ left join keg_valve_combination kegvalveco1_ on
keg0_.bkid=kegvalveco1_.keg where (kegvalveco1_.keg is null)
thanks, Uros
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: