如何在java中同时获取十进制的null和0
我正在尝试从数据库中将 Sugar_per_serving 的 null 和 0.00 检索到 api 中。数据类型为 BigDecimal。现在我在数据库中输入空白,但在api上它显示0。有没有办法将0更改为null?下面是我的代码:
WeightManagement.java
public BigDecimal sugar_per_serving;
public BigDecimal getSugar_per_serving() {
return sugar_per_serving;
}
public void setSugar_per_serving(BigDecimal sugar_per_serving) {
this.sugar_per_serving = sugar_per_serving;
}
PortalDBImpl.java
food.sugar_per_serving=rs.getBigDecimal("sugar_per_serving");
I am trying to get retrieve both null and 0.00 for sugar_per_serving into api from the database. The datatype is BigDecimal. Now I put blank in the database, but on the api it is showing 0. Is there a way to change 0 to null? Below is my code:
WeightManagement.java
public BigDecimal sugar_per_serving;
public BigDecimal getSugar_per_serving() {
return sugar_per_serving;
}
public void setSugar_per_serving(BigDecimal sugar_per_serving) {
this.sugar_per_serving = sugar_per_serving;
}
PortalDBImpl.java
food.sugar_per_serving=rs.getBigDecimal("sugar_per_serving");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅更改选择:
如果需要更新/插入,则更改:
Change only for select:
Change if you need for update/insert: