I want to query with the properties within an embedded type:
@Embeddable
class MCValue {
Currency currency;
BigDecimal value;
}
@Entity
class Record {
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "currency", column = @Column(name = "price_cc")),
@AttributeOverride(name = "value", column = @Column(name = "price")) })
MCValue price;
}
However, in the criteria query, I don’t know how to specify them, or should it even be supported?
I’ve tried but none of these succeeded:
Projections.groupProperty("price_cc")
Projections.groupProperty("price.currency")
Projections.sum("price")
Projections.sum("price.value")
The syntax is indeed
price.currencyandprice.value. Hibernate queries are always written in termes of objects and their fields, and never in terms of database columns.If it doesn’t work, it means that you have some other error in your code. Include the complete code and the exception stack trace.