Reputation: 133
I have a Class which has other objects as it's members fields. e.g.:
class Orders{
private Integer code;
@OneToOne(fetch=FetchType.EAGER)
@JoinColumn(name="code", nullable=false)
private Category category;
private PaymentType pt;
}
class Category{
private Integer id;
@OneToMany(fetch=FetchType.EAGER)
@JoinColumn(name="id", nullable=false)
private Brands brand;
....
}
class Brands{
private Integer id;
private String brandName;
}
I need to get all the Brands for that particular order.
How do I get just the brands through Orders table in Hql?
Upvotes: 0
Views: 1065
Reputation: 21
Are the relations one-to-one? If so, you should be able to query it with:
@Query("SELECT FROM Orders orders.category.brand WHERE ...")
Brands findBrandBy(...);
if you are using Spring data.
Upvotes: 1