UserDO.javahibernate.MappingException當Hibernate的表保存POJO
@Entity
@Table(name = "UserDO")
public class UserDO {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long userId;
private boolean successfullyLinked;
private UserInformation userInformation;
}
UserInformation.java
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "address", "country_code", "currency_code", "email_address", "name", "phone" })
public class UserInformation {
@JsonProperty("address")
@Valid
private Address address;
@JsonProperty("country_code")
@NotNull
private String countryCode;
@JsonProperty("currency_code")
@Size(min = 3, max = 3)
private String currencyCode;
@JsonProperty("email_address")
@NotNull
private String emailAddress;
@JsonProperty("name")
@Valid
@NotNull
private Name name;
@JsonProperty("phone")
@Valid
private Phone phone;
}
我想給UserInformation POJO保存爲UserDO的一部分在休眠。但是,將其作爲Spring Boot應用程序的一部分運行時,會出現錯誤。以下是堆棧跟蹤。
org.springframework.beans.factory.BeanCreationException:錯誤創建名爲 'entityManagerFactory的' 類路徑資源定義[組織/ springframework的的/ boot /自動配置/ ORM/JPA/HibernateJpaAutoConfiguration.class]豆:初始化的調用方法失敗;嵌套異常是javax.persistence.PersistenceException:[PersistenceUnit:默認]無法建立的SessionFactory
所致:javax.persistence.PersistenceException:[PersistenceUnit:默認]無法建立的SessionFactory
所致:有機.hibernate.MappingException:無法確定類型:com.paypal.marketplaces.vaas.api.models.UserInformation,在表:追蹤,對於列:[org.hibernate.mapping.Column(userInformation)]
注意:UserInformation POJO非常複雜,其中的其他對象以及這些對象中的對象(和等等)。任何不需要將UserInformation POJO明確映射到UserDO表的列的解決方案將是優選的。
任何幫助將不勝感激!
感謝您的回答! UserInformation中的每個對象(例如: - Address)是否也需要可嵌入? – ytibrewala
是的,他們必須是 –