SpringBoot JPA 实体映射类中如何使用[email protected]

SpringBoot利用JPA做实体映射,promember表里无法映射preson类作为当前promember表的一列,该怎么处理呢


源程序如下图:报错Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: com.wyx.pro.graduation.promembers.Preson, at table: promember, for columns: [org.hibernate.mapping.Column(preson)

SpringBoot JPA 实体映射类中如何使用[email protected]


首先建立外键关联列addressId,利用注解@OneToOne将address绑定到addressId上,

需要注意表的操作updat与insert为false

查询个人信息结果中会自动带上address

[{"password":"wyx123456","address":{"id":1,"province":"1","city":"1","district":"1","street":"1"},"roleIds":["0","1","2"],"name":null,"dateOfBirth":"19980503","avatar":null,"id":"2019","projectIds":["1"],"email":"[email protected]","addressid":1}]

SpringBoot JPA 实体映射类中如何使用[email protected]
OneToOne注解的使用