I Am using hibernate and i have a Entity like
@Entity
@Table(name = "MyEntity")
Class MyEntity {
@Id
@GeneratedValue
private long id;
@Column(name = "NAME")
private String name;
//some more attributes here
@OneToOne
@JoinColumn(name = "PARENT_ID")
MyEntity parent;
}
I have one record in database
id | name | parent_id
125 | n1 | null
and when i am trying to get this record with hibernate Query
Select e.id,e.name,e.parent.name from MyEntity e where e.id =125
this query is returning me zero records.because the parent is null here, so is there any way to handle this kind of situation. thanks in advc.