【发布时间】:2020-02-09 11:35:31
【问题描述】:
由于@OneToOne,我收到此错误。提交响应后无法调用 sendError() 有人可以帮我弄清楚如何解决它吗?
这是我的模型:
@Entity
@SequenceGenerator(name = "RECOMMENDATION_SQ", sequenceName = "recommendation_sequence")
public class Review {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "RECOMMENDATION_SQ")
private Long id;
@ManyToOne
private Restaurant restaurant;
@ManyToOne
private User user;
private Date date;
@Lob
private byte[] image;
private String text;
@OneToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JoinColumn(name="id_rating")
private Rating rating;
--
@Entity
@SequenceGenerator(name = "RATING_SQ", sequenceName = "rating_sequence")
public class Rating {
@Id
@GeneratedValue
private Long id_rating;
@OneToOne(fetch=FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "rating")
@JsonIgnore
private Review review;
private int dish;
private int service;
private int price;
private int location;
private int accessibility;
我尝试添加@JsonIgnore(此解决方案:Spring Boot : Error :Cannot call sendError() after the response has been committed)但我收到此错误:
InvalidDefinitionException: No serializer found for class
org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create
BeanSerializer
我也尝试删除 fetch 类型,但它也不起作用。
【问题讨论】: