【发布时间】:2019-09-14 04:59:17
【问题描述】:
我正在开发一个应用程序 angular 6 / spring boot。我有以下关系: 当我尝试持久化 Quote 对象时,如果 Customer 对象为空,它会起作用。但是,如果我想与客户保持 Quote 对象,我会收到消息:
@实体 @遗产 公共抽象类 Customer 实现 Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long idCustomer;
@Column(unique = true)
@NotNull
private String code;
private String name;
private String address;
private String email;
private String phone;
private String city;
@OneToMany(mappedBy="customer")
private List<Order> orders;
private byte status;
@OneToMany(mappedBy="customer")
private List<Quote> quote;
@JoinColumn(name="country")
@ManyToOne
private Country country;
@Entity
public class Individual extends Customer{
private String firstname;
private String gender;
@Entity
public class Company extends Customer implements Serializable{
private static final long serialVersionUID = 1L;
@NotNull
private String legalForm;
@Entity
public class Quote implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long idQuote;
private LocalDate dateQuote;
@OneToMany(fetch = FetchType.EAGER, mappedBy="quote",
cascade=CascadeType.ALL)
private List<QuoteLine> items;
@ManyToOne
@JoinColumn(name="id_customer",nullable=false)
private Customer customer;
com.fasterxml.jackson.databind.exc.InvalidDefinitionException:无法构造com.pam.entities.Customer 的实例(没有创建者,如默认构造,存在):抽象类型要么需要映射到具体类型,要么具有自定义反序列化器,要么包含附加类型信息
【问题讨论】: