保存数据时向我显示以下错误: 在de.pares.int_plan.entity.DepositDeadlineEntity.negFive null的getter内部发生异常
我们在后端使用了Java和ORM休眠。 我从前端获取数据并保存。通常这是可行的,但不幸的是在这种情况下不可行。而且我不知道我到底在做什么错。
代码
public PlanlinevaluesEntity changePlanValues(PlanlinevaluesEntity plan, Map requestBody) throws IllegalAccessException {
...
...
...
for (Object key : requestBody.keySet()) {
if (!key.equals("depositDeadlineId")) {
for (Field field : ddFields) {
if (field.getName().equals(key)) {
DepositDeadlineEntity ddE = new DepositDeadlineEntity();
DepositDeadlineManager ddM = new DepositDeadlineManager();
ddE.applyValue(field, requestBody.get(key));
ddE.setPlanlinevaluesId(plan.getPlanlinevaluesId());
ddM.saveOrUpdate(ddE);
if (ddE.getDepositDeadlineId() != null && ddE.getDepositDeadlineId() > 0) {
plan.setDepositdeadlineId(ddE.getDepositDeadlineId());
new PlanLineValuesManager().saveOrUpdate(plan);
}
}
}
}
}
}
...
...
...
我的实体如下:
@Entity
@Table(name = "deposit_deadline")
public class DepositDeadlineEntity {
private Long depositDeadlineId;
private Long planlinevaluesId;
private Double posSeven;
private Double posSix;
private Double posFive;
private Double posFour;
private Double posThree;
private Double posTwo;
private Double posOne;
private Double zero;
private Double negOne;
private Double negTwo;
private Double negThree;
private Double negFour;
private Double negFive;
private Double negSix;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "deposit_deadline_id", nullable = false)
public Long getDepositDeadlineId() {
return depositDeadlineId;
}
public void setDepositDeadlineId(Long depositDeadlineId) {
this.depositDeadlineId = depositDeadlineId;
}
@Basic
@Column(name = "planlinevalues_id", nullable = false)
public Long getPlanlinevaluesId() { return planlinevaluesId; }
public void setPlanlinevaluesId(Long planlinevaluesId) { this.planlinevaluesId = planlinevaluesId; }
@Basic
@Column(name = "pos_seven", nullable = false)
public double getPosSeven() {
return posSeven;
}
public void setPosSeven(double posSeven) {
this.posSeven = posSeven;
}
@Basic
@Column(name = "pos_six", nullable = false)
public double getPosSix() {
return posSix;
}
public void setPosSix(double posSix) {
this.posSix = posSix;
}
@Basic
@Column(name = "pos_five", nullable = false)
public double getPosFive() {
return posFive;
}
public void setPosFive(double posFive) {
this.posFive = posFive;
}
@Basic
@Column(name = "pos_four", nullable = false)
public double getPosFour() {
return posFour;
}
public void setPosFour(double posFour) {
this.posFour = posFour;
}
@Basic
@Column(name = "pos_three", nullable = false)
public double getPosThree() {
return posThree;
}
public void setPosThree(double posThree) {
this.posThree = posThree;
}
@Basic
@Column(name = "pos_two", nullable = false)
public double getPosTwo() {
return posTwo;
}
public void setPosTwo(double posTwo) {
this.posTwo = posTwo;
}
@Basic
@Column(name = "pos_one", nullable = false)
public double getPosOne() {
return posOne;
}
public void setPosOne(double posOne) {
this.posOne = posOne;
}
@Basic
@Column(name = "zero", nullable = false)
public double getZero() {
return zero;
}
public void setZero(double zero) {
this.zero = zero;
}
@Basic
@Column(name = "neg_one", nullable = false)
public double getNegOne() {
return negOne;
}
public void setNegOne(double negOne) {
this.negOne = negOne;
}
@Basic
@Column(name = "neg_two", nullable = false)
public double getNegTwo() {
return negTwo;
}
public void setNegTwo(double negTwo) {
this.negTwo = negTwo;
}
@Basic
@Column(name = "neg_three", nullable = false)
public double getNegThree() {
return negThree;
}
public void setNegThree(double negThree) {
this.negThree = negThree;
}
@Basic
@Column(name = "neg_four", nullable = false)
public double getNegFour() {
return negFour;
}
public void setNegFour(double negFour) {
this.negFour = negFour;
}
@Basic
@Column(name = "neg_five", nullable = false)
public double getNegFive() {
return negFive;
}
public void setNegFive(double negFive) {
this.negFive = negFive;
}
@Basic
@Column(name = "neg_six", nullable = false)
public double getNegSix() {
return negSix;
}
public void setNegSix(double negSix) {
this.negSix = negSix;
}
public void applyValue(Field field, Object value) throws IllegalAccessException {
field.set(this, ObjectFieldValueConverter.convert(field, value));
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DepositDeadlineEntity that = (DepositDeadlineEntity) o;
return depositDeadlineId.equals(that.depositDeadlineId) &&
posSeven.equals(that.posSeven) &&
posSix.equals(that.posSix) &&
posFive.equals(that.posFive) &&
posFour.equals(that.posFour) &&
posThree.equals(that.posThree) &&
posTwo.equals(that.posTwo) &&
posOne.equals(that.posOne) &&
zero.equals(that.zero) &&
negOne.equals(that.negOne) &&
negTwo.equals(that.negTwo) &&
negThree.equals(that.negThree) &&
negFour == that.negFour &&
negFive == that.negFive &&
negSix == that.negSix;
}
@Override
public int hashCode() {
return Objects.hash(depositDeadlineId, posSeven, posSix, posFive, posFour, posThree, posTwo, posOne, zero, negOne, negTwo, negThree, negFour, negFive, negSix);
}
Nullable = false是sql级别的拦截器。 由于数据来自前端,因此我可以排除使用negFive解决该吸气剂
{
"posOne": 70,
"negOne" : 30
}
有人知道这个错误或我在做什么错吗?