JPA - 变量 double 正在四舍五入
JPA - variables double are being rounded
我有一个这样的模型实体:
@Entity
public class Produtos{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String nome;
private Long quantidade;
private boolean frete;
private Double precoNovo;
private Double precoAntigo;
private boolean promocao;
private boolean variacaoCor;
private String[] cores;
private String corUnica;
}
当我使用 (private Double precoAntigo) 保存产品价格时,spring 将值四舍五入,例如:2500.50 到 2500,如何禁用此选项?
https://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/Column.html#precision()
https://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/Column.html#scale()
@Column(scale=2)
private Double precoNovo;
@Column(scale=2)
private Double precoAntigo;
我有一个这样的模型实体:
@Entity
public class Produtos{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String nome;
private Long quantidade;
private boolean frete;
private Double precoNovo;
private Double precoAntigo;
private boolean promocao;
private boolean variacaoCor;
private String[] cores;
private String corUnica;
}
当我使用 (private Double precoAntigo) 保存产品价格时,spring 将值四舍五入,例如:2500.50 到 2500,如何禁用此选项?
https://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/Column.html#precision() https://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/Column.html#scale()
@Column(scale=2)
private Double precoNovo;
@Column(scale=2)
private Double precoAntigo;