please consider following class:
class A{
@Column(name="ID")
int id;
@Column(name="CODE")
String code;
@Column(name="NAME")
String name;
@Column(name="ID2")
int id2;
@Transient
@ManyToOne(fetch = FetchType.LAZY, optional = true)
@JoinColumns({ @JoinColumn(name = "CODE"), @JoinColumn(name = "ID2") })
@Where(clause="parent.name is NULL")
A parent;
public A getParent(){
this.parent;
}
}
I need to retrieve the parent of object based on those conditions: above code does not work and would you please help me out to solve it.
P.S: Parent sql query alike:
select b.* from A a inner join A b
on a.code = b.code
and a.id2 = b.id2
where b.name is null;