我在我的应用程序中使用BigDecimal作为我的数字,例如,使用JPA.我对"精确度"和"规模"这两个术语进行了一些研究,但我不明白它们究竟是什么.
任何人都能解释一下BigDecimal值的'precision'和'scale'的含义吗?
@Column(precision = 11, scale = 2)
Run Code Online (Sandbox Code Playgroud)
谢谢!
I'm having problems when saving entities in my DB.
I have something like (very simplified) :
@Entity
public class Building {
@OneToMany(mappedBy = "building", fetch = FetchType.EAGER)
private List<Employee> employees;
}
@Entity
public class Employee {
@NotNull
@ManyToOne
@JoinFetch(INNER)
@JoinColumn
private Building building;
@PostLoad
private void onLoad(){
if (this.plannedOrder == null) {
//For old entities in this DB, update plannedOrder if null
if (this.order < FIRST.getCode()) {
this.plannedOrder = FIRST;
} else if (this.order >= FIRST.getCode() && this.order < SECOND.getCode()) …Run Code Online (Sandbox Code Playgroud) 我有一个带有调用另一种方法的方法的服务。在第一种方法中,我只使用 SELECT 执行查询,但他们必须查看在第二种方法中完成的 INSERTS 和 UPDATES。
然后,我必须处理交易。我正在使用 Spring,所以我可以使用 @Transactional 注释。
以下哪个选项似乎更适合您?
选项 A
@Transactional
public void generate(){
// selects
save(a);
// more selects
}
@Transactional
public void save(Object a){
//save the object
}
Run Code Online (Sandbox Code Playgroud)
选项 B
public void generate(){
// selects
save(a);
// more selects
}
@Transactional
public void save(Object a){
//save the object
}
Run Code Online (Sandbox Code Playgroud)
谢谢!!
java ×3
jpa ×3
bigdecimal ×1
cascade ×1
eclipselink ×1
many-to-one ×1
precision ×1
scale ×1
spring ×1