方法抛出' org.springframework.dao.DataIntegrityViolationException'例外

时间:2016-10-12 07:05:24

标签: java spring oracle hibernate jpa

我有这个实体

@Entity
@Table(name = "REPORT_TASCK")
@Data
public class ReportTasck {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    public Long id;
    @Column(name = "type")
    public String type;
    @Column(name = "status")
    public Integer status;
    @Column(name = "type")
    @OneToMany(mappedBy = "reportTasck", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    public List<Bill> bills;
}

@Entity
@Table(name = "BIIL")
@Data
public class Bill {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    public Long id;
    @Column(name = "neme")
    public String neme;
    @Column(name = "status")
    public Integer status;
    @ManyToOne()
    @JoinColumn(name = "REPORT_TASCK_ID")
    public ReportTasck reportTasck;
}

然后我尝试填写并保存

ReportTasck reportTasck = new ReportTasck();
        reportTasck.setStatus(0);
        reportTasck.setType("standart");
        List<Bill> bills = new ArrayList<>();
        for (BillDto billDto : all) {//640 items
           Bill bill = new Bill();
            bill.setStatus(0);
            bill.setNeme(billDto.getBill());
            bill.setReportTasck(reportTasck);
            bills.add(bill);
        }
        reportTasck.setBills(bills);
        reportTasckRepository.save(reportTasck);

但是当开始这一行reportTasck.setBills(bills);时,我在debbug模式下出错了方法扔了'java.lang.StackOverflowError' exception. Cannot evaluate entity.ReportTasck.toString()

当我尝试保存时,我收到此错误Method threw 'org.springframework.dao.DataIntegrityViolationException' exception.

could not execute statement; SQL [n/a]; constraint [null]

我不明白为什么我会收到此错误以及如何修复

0 个答案:

没有答案