-->
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.  [ 1 post ] 
Author Message
 Post subject: HQL: Left Join On with using reference to two entities
PostPosted: Thu Jan 16, 2014 2:33 am 
Newbie

Joined: Thu Jan 16, 2014 2:22 am
Posts: 1
I had create the issue (https://hibernate.atlassian.net/browse/HHH-8868) but was redirected to there.

There some entities and HQL query:

Quote:
@Entity
public class Visit implements Serializable
Unknown macro: { @Id private Integer id; @JoinColumn(name = "ID_SLUCH_MED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Sluch idSluchMed; @Temporal(TemporalType.TIMESTAMP) private Date visitDate; }

@Entity
public class Sluch implements Serializable
Unknown macro: { @Id private Integer id; @JoinColumn(name = "ID_INSURED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Insured idInsured; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSluchMed", fetch = FetchType.LAZY) private List<Visit> visitList; }

@Entity
public class Insured implements Serializable
Unknown macro: { @Id private Integer id; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idInsured", fetch = FetchType.LAZY) private List<Sluch> sluchList; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idInsured", fetch = FetchType.LAZY) private List<HistInvalid> histInvalidList; }

@Entity
public class HistInvalid implements Serializable
Unknown macro: { @Id private Integer id; @Column(name = "BEGDATE") @Temporal(TemporalType.TIMESTAMP) private Date begdate; @Column(name = "ENDDATE") @Temporal(TemporalType.TIMESTAMP) private Date enddate; @JoinColumn(name = "ID_INSURED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Insured idInsured; }

SELECT v
FROM Visit v
LEFT JOIN v.idSluchMed s
LEFT JOIN s.idInsured i
LEFT JOIN i.histInvalidList h
ON h.begdate < v.visitDate


And I have the following exception:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements

Please, tell me about how I can write this query.


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

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.