问题:
Caused by: org.hibernate.MappingException: Could not determine type for: com.cloudage.membercenter.entity.Article, at table: Comment, for columns: [org.hibernate.mapping.Column(article)]
解决办法
在BaseEntity 里面,由于id前面的声明
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)放在了Integer id;的前面;
而其他的@Id等等那些都是放在
getId()
等等方法的前面,
所以,由于位置不一样而导致;
统一放在getXXX()方法前面 或者统一放在 Integer XXX ; 前面即可;
本文解决了在使用 Hibernate 时遇到的 MappingException 错误,该错误发生在尝试映射 com.cloudage.membercenter.entity.Article 实体类到 Comment 表时。问题的根源在于 @Id 注解的位置不一致,通过将 @Id 和其他相关注解统一放置于 get 方法前或字段声明前,成功解决了此问题。
1124

被折叠的 条评论
为什么被折叠?



