I have a @Entity called Order in this I have a field or a member variable called orderEmails as show below.
@Entity
@Table(name = "order")
public class Order {
@Id
@Column(name = "order_int")
private Long id;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "order_int", insertable = false, updatable = false)
private List<OrderEmail> orderEmails;
... }
I am trying to create Projections on this Order , meaning I want to select some specific columns from the Order entity and a column from the OrderEmail entity
But, when I create a projection on the orderEmails field. I don't get the complete list of emails. Which is what I want. Here is the code that I am trying
ProjectionList columnList = Projections.projectionList();
...
columnList.add(Projections.property("id").as("id"));
...
columnList.add(Projections.property("orderemails.EmailAddress").as("email"));
Note, I have also tried columnList.add(Projections.property("orderemails").as("email")); and changed the email (in as) to be a List, but didn't help
Is it possible to create a projection on a List in Hibernate ?