I have a simple inheritance model of "Property" and three subclasses "Residential", "Commercial", and "Land". I am using the JOINED inheritance strategy. For some reason when I just query the root "Property" class, Hibernate joins all the subclasses - which is what I don't want. I would like to perform an efficient search on just the root "Property" class/table. The code I have is below.... Is there an annotation that will allow me to query the root table and not join the subclasses?
Code:
@Entity
@Table(name = "Property")
@Inheritance(strategy = InheritanceType.JOINED)
public class Property implements Serializable {
@Id
@Column(name = "Uid")
private Integer uid;
}
Code:
@Entity
@Table(name = "Residential")
public class Residential extends Property implements Serializable{
@Column(name = "SqFt", length = 10)
private String sqFt;
}
Code:
String query = "SELECT property from Property property";
Query q = em.createQuery(query);
list = (List<NtreisPrp>) q.getResultList();