for example, if there is an @ElementCollection
file which is with a Map
type, then if I try to get the map key or value field then how to process?
Class Deal{
.....
private String name;
private String department;
private DealType type;
@AttributeOverrides({
@AttributeOverride(name="value.in.available", column=@Column(name="in_avl")),
@AttributeOverride(name="value.in.unavailable", column=@Column(name="in_unv")),
@AttributeOverride(name="value.out.available", column=@Column(name="out_avl")),
@AttributeOverride(name="value.out.unavailable", column=@Column(name="out_unv"))
})
@ElementCollection(fetch = FetchType.EAGER)
......
}
So if I try to get something like this
select new SummaryAmount(SUM(t.value.in.available), SUM(t.value.in.unavailable),
SUM(t.value.out.available), SUM(t.value.out.unavailable)) from Deal AS d INNER
JOIN d.transactionAmounts t GROUP by t.key;
Is it something possible can work out now? Everything is follow the book except I invent the t.value
and t.key
as I really don't know how to present map key and value in JPQL.Thanks
Thanks
Try this:
And now an excerpt from the JPA specification: