【发布时间】:2017-10-02 17:53:36
【问题描述】:
UserDO.java
@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 保存为 Hibernate 中 UserDO 的一部分。但是,在将其作为 Spring Boot 应用程序的一部分运行时,出现错误。以下是堆栈跟踪。
org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class] 中定义名称为“entityManagerFactory”的 bean 创建错误:调用 init 方法失败;嵌套异常是 javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
原因:javax.persistence.PersistenceException: [PersistenceUnit: default] 无法构建 Hibernate SessionFactory
原因:org.hibernate.MappingException:无法确定类型:com.paypal.marketplaces.vaas.api.models.UserInformation,在表:跟踪,列:[org.hibernate.mapping.Column(userInformation )]
注意:UserInformation POJO 非常复杂,其中包含其他对象以及这些对象中的对象(等等)。任何不需要将 UserInformation POJO 显式映射到 UserDO 表的列的解决方案都是可取的。
任何帮助将不胜感激!
【问题讨论】:
标签: java spring hibernate spring-boot jpa