@Entity
@Table(name="casehistory")
public class CaseHistory{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name="case_id")
private Case case;
}
@Entity
@Table(name="cases")
public class Case {
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany(mappedBy="case_id",cascade = CascadeType.ALL)
private List<CaseHistory> caseHistories;
}
I have this two entities. if I write query like this:
StringBuilder queryString=new StringBuilder("SELECT DISTINCT ch.case.id from CaseHistory ch where ch.date>=:fromDate AND ch.date<:toDate and ch.case.id=ch.case.id");
StringBuilder queryString=new StringBuilder("SELECT DISTINCT ch.case.id from CaseHistory ch,Case c where ch.date>=:fromDate AND ch.date<:toDate and c.id=ch.case.id");
both are equivalent or what?