I have the following relation of three classes:
@Entity
public class User{
@OnetoMany
List<Attribute> attributes = new ArrayList<Attribute>();
}
@Entity
public class Attribute{
@ManyToOne
AttributeType attributeType;
}
@Entity
public class AttributeType{
@Column
String type;
}
One user can have n attributes of m types.
I need to create HQL query which will return all Atribute Types List<AttributeType> of specific user attributes.
For example user has attribute a of type t, atribute b of type t and attribute c of type t1.
I need to return List<AttributeType> which will contain t and t1.
Please help. I just got lost in this query.
You shall map Attribute to User many to one relation, so the following query is what you need:
I think the following query will work too: