Java Hibernate将默认值设置为select if null

Java Hibernate将默认值设置为select if null,java,hibernate,jpa,Java,Hibernate,Jpa,如何设置的默认值 select sum(i.price), i.category from item as i where i.customer=:customer group by i.category. 因此,如果客户创建他们的类别并购买类别中的某些项目,我的查询将正常运行。但是,如果客户只创建他们的类别而不购买任何项目,则不会返回该数据。如何返回类别并显示0 我曾尝试将其放入getter中,但效果不佳: @Column(name="price", columnDefinition="Bi

如何设置的默认值

select sum(i.price), i.category from item as i where i.customer=:customer group by i.category.
因此,如果客户创建他们的类别并购买类别中的某些项目,我的查询将正常运行。但是,如果客户只创建他们的类别而不购买任何项目,则不会返回该数据。如何返回类别并显示0

我曾尝试将其放入getter中,但效果不佳:

@Column(name="price", columnDefinition="BigDecimal default 0")
public BigDecimal getPrice;
private BigDecimal price;
您可以使用:

@列(name=“price”)
私有BigDecimal getPrice=0


希望这能有所帮助。

为什么不通过执行
private BigDecimal price=0
以便查询不会返回null。与
category=“notset”