This question answers the opposite relationship. I have been trying to come up with a Criteria Query for the following model:
@Entity
public class One {
@Id
private BigInteger supplierId;
@Column(name = "name")
String name;
...
}
@Entity
public class Many {
@Id
private BigInteger posId;
@ManyToOne
@JoinColumn(name = "column_name")
One one;
@Column(name = "description")
String description;
}
I cannot change the model. I most keep it unidirectional in that way. I am trying to come up with the Criteria Builder code for the following situation:
-I will be given the following attributes: nam
, desc
. I need to find all the One
entities whose name attribute is equal to nam
, and that have a related Many
entity whose description attribute is equal to desc