in enthesaplasmaek entity, i made relationship as below with my two entities, EntHesaplasma and EntHesaplasmaek
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="hesaplasmaekid",referencedColumnName="carihareketid",insertable=false,updatable=false)
@Where(clause = "enthesaplasma.evraktip='EK'")
public EntHesaplasma getEnthesaplasma() {
return enthesaplasma;
}
when i run the below hql , hibernate makes a relationship between hesaplasmaekid and hesaplasmaid (primary key (@Id) of enthesaplasma entity). But the correct relationship should be between carihareketid in enthesaplasma entity and enthesaplasmaekid in the enthesaplasmaek entity.
select hs.hesaplasmaid,hs.carihareketid,ek.hesaplasmaekid,hs.hesaplasmano,ek.aciklama from EntHesaplasmaek ek left join ek.enthesaplasma hs
Result of the query (from Hibernate Query Editor in eclipse)
how can i correct this error ? thanks.
My entities are below
EntHesaplasma entity
@Entity
@Table(name = "XOZ_HESAPLASMA")
public class EntHesaplasma {
Integer hesaplasmaid;
@Transient
EntCariHareketler carihareket;
@Resolvable(colName = "Hesaplaşma No",formatter=FormatterInteger.class)
Integer hesaplasmano;
Integer hesaplasmagrupid;
Date datecreated;
Integer carihareketid;
String evraktip;
Boolean isactive;
Double meblag;
EntHesaplasmagrup enthesaplasmagrup;
EntHesaplasmaek enthesaplasmaek;
@Id
@GeneratedValue
@Column(name = "hesaplasmaid", unique = true, nullable = false)
public Integer getHesaplasmaid() {
return hesaplasmaid;
}
public void setHesaplasmaid(Integer hesaplasmaid) {
this.hesaplasmaid = hesaplasmaid;
}
@Column(name = "datecreated")
public Date getDatecreated() {
return datecreated;
}
public void setDatecreated(Date datecreated) {
this.datecreated = datecreated;
}
@Column(name = "hesaplasmano")
public Integer getHesaplasmano() {
return hesaplasmano;
}
//@OneToOne(fetch= FetchType.LAZY)
//@JoinColumn(name="carihareketid")
@Transient
public EntCariHareketler getCarihareket() {
return carihareket;
}
public void setCarihareket(EntCariHareketler carihareket) {
this.carihareket = carihareket;
}
public void setHesaplasmano(Integer hesaplasmano) {
this.hesaplasmano = hesaplasmano;
}
@Column(name = "carihareketid")
public Integer getCarihareketid() {
return carihareketid;
}
public void setCarihareketid(Integer carihareketid) {
this.carihareketid = carihareketid;
}
@Column(name="isactive")
public Boolean getIsactive() {
return isactive;
}
public void setIsactive(Boolean isactive) {
this.isactive = isactive;
}
@Column(name="meblag")
public Double getMeblag() {
return meblag;
}
public void setMeblag(Double meblag) {
this.meblag = meblag;
}
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="hesaplasmagrupid")
public EntHesaplasmagrup getEnthesaplasmagrup() {
return enthesaplasmagrup;
}
public void setEnthesaplasmagrup(EntHesaplasmagrup enthesaplasmagrup) {
this.enthesaplasmagrup = enthesaplasmagrup;
}
@Column(name="hesaplasmagrupid",insertable=false,updatable=false)
public Integer getHesaplasmagrupid() {
return hesaplasmagrupid;
}
public void setHesaplasmagrupid(Integer hesaplasmagrupid) {
this.hesaplasmagrupid = hesaplasmagrupid;
}
@Column(name="evraktip")
public String getEvraktip() {
return evraktip;
}
public void setEvraktip(String evraktip) {
this.evraktip = evraktip;
}
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="carihareketid",referencedColumnName="hesaplasmaekid",insertable=false,updatable=false)
@Where(clause = "evraktip='EK'")
public EntHesaplasmaek getEnthesaplasmaek() {
return enthesaplasmaek;
}
public void setEnthesaplasmaek(EntHesaplasmaek enthesaplasmaek) {
this.enthesaplasmaek = enthesaplasmaek;
}
}
EntHesaplasmaek entity
@Entity
@Table(name = "XOZ_HESAPLASMAEK")
public class EntHesaplasmaek {
Integer hesaplasmaekid;
@Resolvable(colName="Bakiye",formatter=DoubleFormatter.class)
Double bakiye;
@Resolvable(colName="Açıklama")
String aciklama;
Integer konuid;
Boolean boolzamanlanmis;
Integer zamanid;
Date datecreated;
@Resolvable(colName="Tarih",formatter=DateFormatterTbl.class)
Date evraktarih;
@Resolvable(colName="Hesaplasma No",formatter=FormatterInteger.class)
@Transient
Integer hesaplasmano;
Integer hesaplasmagrupid;
EntHesaplasmagrup enthesaplasmagrup;
EntHesaplasma enthesaplasma;
@Id
@GeneratedValue
@Column(name = "hesaplasmaekid", unique = true, nullable = false)
public Integer getHesaplasmaekid() {
return hesaplasmaekid;
}
public void setHesaplasmaekid(Integer hesaplasmaekid) {
this.hesaplasmaekid = hesaplasmaekid;
}
@Column(name="bakiye")
public Double getBakiye() {
return bakiye;
}
public void setBakiye(Double bakiye) {
this.bakiye = bakiye;
}
@Column(name="aciklama")
public String getAciklama() {
return aciklama;
}
public void setAciklama(String aciklama) {
this.aciklama = aciklama;
}
@Column(name="konuid")
public Integer getKonuid() {
return konuid;
}
public void setKonuid(Integer konuid) {
this.konuid = konuid;
}
@Column(name="boolzamanlanmis")
public Boolean getBoolzamanlanmis() {
return boolzamanlanmis;
}
public void setBoolzamanlanmis(Boolean boolzamanlanmis) {
this.boolzamanlanmis = boolzamanlanmis;
}
@Column(name="zamanid")
public Integer getZamanid() {
return zamanid;
}
public void setZamanid(Integer zamanid) {
this.zamanid = zamanid;
}
@Column(name="datecreated")
public Date getDatecreated() {
return datecreated;
}
public void setDatecreated(Date datecreated) {
this.datecreated = datecreated;
}
@Column(name="evraktarih")
public Date getEvraktarih() {
return evraktarih;
}
public void setEvraktarih(Date evraktarih) {
this.evraktarih = evraktarih;
}
@Transient
public Integer getHesaplasmano() {
return hesaplasmano;
}
public void setHesaplasmano(Integer hesaplasmano) {
this.hesaplasmano = hesaplasmano;
}
@Column(name="hesaplasmagrupid",insertable=false,updatable=false)
public Integer getHesaplasmagrupid() {
return hesaplasmagrupid;
}
public void setHesaplasmagrupid(Integer hesaplasmagrupid) {
this.hesaplasmagrupid = hesaplasmagrupid;
}
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="hesaplasmagrupid")
public EntHesaplasmagrup getEnthesaplasmagrup() {
return enthesaplasmagrup;
}
public void setEnthesaplasmagrup(EntHesaplasmagrup enthesaplasmagrup) {
this.enthesaplasmagrup = enthesaplasmagrup;
}
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="hesaplasmaekid",referencedColumnName="carihareketid",insertable=false,updatable=false)
@Where(clause = "enthesaplasma.evraktip='EK'")
public EntHesaplasma getEnthesaplasma() {
return enthesaplasma;
}
public void setEnthesaplasma(EntHesaplasma enthesaplasma) {
this.enthesaplasma = enthesaplasma;
}
}