异常栈Could not determine type for: java.util.Set
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: user_role, for columns: [org.hibernate.mapping.Column(roles)]
代码片段
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = “user_role”, joinColumns = { @JoinColumn(name = “user_id”) }, inverseJoinColumns = { @JoinColumn(name = “role_id”) })
private Set roles = new HashSet();
这里写代码片
解决方法:
- 保持注解位置一致,要么全在字段上,要么全在getter方法上
- 检查注解是否完整,如果缺少@ManyToMany也会出现该异常