I'm using Hibernate 3.2.0CR1 (distributed with JBoss 4.0.4 GA). I have an entity that looks like this (just mentioning the meaningful attributes):
Code:
@Entity
public class SomeEntity {
@Id
private Integer id;
@ManyToOne(optional = true)
@JoinColumn(name = "OTHER", nullable = true)
private OtherEntity other;
// other properties, getters and setters
}
@Entity
public class OtherEntity { ... }
Note that I can leave SomeEntity.other null. Now, when I query "select e from SomeEntity e" everything works fine. At a certain point I just want to get the "id" and "other" properties of a specific SomeEntity. The obvious way to do it would be to query "select e.id, e.other from SomeEntity e where e.id=:id". However, if "other" is null, the query returns no result at all.
Is there any way to get this query to return an array containing the id on the first position and null on the second?