java - org.hibernate.MappingException:无法确定类型:表中的类:table1,列:[org.hibernate.mapping.Column(end_table2)]
问题描述
我知道这种问题之前已经发布过。但是我在网上尝试了所有解决方案,但没有一个能解决我的问题。我从事Spring-MVC项目,在业务逻辑层中我定义了几个要映射到数据库的实体。我在 2 个类之间建立了多对多关系:Monument
和Circuit
. 但我得到这个错误:
org.hibernate.MappingException: Could not determine type for: com.entities.Monument, at table: circuit, for columns: [org.hibernate.mapping.Column(end_monument)]
这是我的第一堂课:
@Entity
@Table(name = "monument")
public class Monument {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "latitude")
private double latitude;
@Column(name = "longtitude")
private double longtitude;
@Column(name = "name")
private String name;
@Column(name = "foundation_date")
private Date foundationDate;
@Column(name = "description")
private String description;
@ManyToMany(fetch = FetchType.LAZY, cascade = {
CascadeType.DETACH,
CascadeType.MERGE,
CascadeType.PERSIST,
CascadeType.REFRESH })
@JoinTable(name = "circuit_monument",
joinColumns = @JoinColumn(name = "monument_id"),
inverseJoinColumns = @JoinColumn(name = "circuit_id"))
private List<Circuit> circuits;
// constructors & getters é setters
}
我的第二堂课:
@Entity
@Table(name = "circuit")
public class Circuit {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "start_monument")
private Monument start;
@Column(name = "end_monument")
private Monument end;
@ManyToMany(fetch = FetchType.LAZY, cascade = {
CascadeType.DETACH,
CascadeType.MERGE,
CascadeType.PERSIST,
CascadeType.REFRESH })
@JoinTable(name = "circuit_monument",
joinColumns = @JoinColumn(name = "circuit_id"),
inverseJoinColumns = @JoinColumn(name = "monument_id"))
private List<Monument> monuments;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "circuit_id")
private List<Comment> comments;
// constructors & getters & setters
}
这是异常堆栈跟踪:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'touristController': Unsatisfied dependency expressed through field 'touristService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'touristServiceImp': Unsatisfied dependency expressed through field 'touristDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'touristDaoImp': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.configuration.AppConfig: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: com.entities.Monument, at table: circuit, for columns: [org.hibernate.mapping.Column(end_monument)]
解决方案
推荐阅读
- python - python中的NameError试图创建一个BMI计算器
- delphi - TGrid 不能与 iOS 模拟器一起工作——它只是短暂运行,安装后就消失了
- html - 嵌套的 JSON 输出到 HTML 表
- python - F 字符串不打印
- c++ - VSCode - 启用 code-runner.runInTerminal 时,C++ 代码运行器无法正常工作
- javascript - 如果 Django 模型字段中有新数据,则使用 AJAX 加载新数据
- javascript - 按下复选框时使用 CSS 显示/隐藏
- flutter - 参数类型'Future
'不能分配给参数类型'double' - css - 用于显示和居中元素的引导响应媒体查询在 Ralis 上不起作用
- qt - QML 加载程序:检测到属性“y”的绑定循环