Я знаю, что подобные вопросы были опубликованы ранее.Но я попробовал все решения онлайн, и ни одно из них не устранило мою проблему.Я работаю над проектом 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)]