org.hibernate.MappingException:无法确定类型:java.util.List,在 table:Schedule_assignedRoles,对于列:assignedRoles
org.hibernate.MappingException: Could not determine type for: java.util.List, at table: Schedule_assignedRoles, for columns: assignedRoles
我需要帮助,我正在尝试使用地图,但我遇到了这个错误:
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: Schedule_assignedRoles, for columns: [org.hibernate.mapping.Column(assignedRoles)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:390)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:363)
at org.hibernate.mapping.Collection.validate(Collection.java:310)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:74)
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:333)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802)
这里是我的代码:
@Entity
public class Schedule extends PersistentObject implements Comparable<Schedule> {
private String title;
@ManyToOne
private Agent target;
@ElementCollection
@MapKeyColumn(nullable = false)
@Column(nullable = false)
private Map<Long, List<Role>> assignedRoles = new HashMap<>();
//gets e setters
}
谢谢! :D
我认为使用 @ManyToMany
或 @OneToMany
足以完成您的任务
@Entity
public class Schedule extends PersistentObject implements Comparable<Schedule> {
@Column
private String title;
@ManyToOne
private Agent target;
@OneToMany
private List<Unit> units = new List<>();
}
@Entity
public class Unit {
@ManyToMany
private List<Role> assignedRoles = new List<>();
}
我需要帮助,我正在尝试使用地图,但我遇到了这个错误:
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: Schedule_assignedRoles, for columns: [org.hibernate.mapping.Column(assignedRoles)] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:390) at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:363) at org.hibernate.mapping.Collection.validate(Collection.java:310) at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:74) at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:333) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802)
这里是我的代码:
@Entity
public class Schedule extends PersistentObject implements Comparable<Schedule> {
private String title;
@ManyToOne
private Agent target;
@ElementCollection
@MapKeyColumn(nullable = false)
@Column(nullable = false)
private Map<Long, List<Role>> assignedRoles = new HashMap<>();
//gets e setters
}
谢谢! :D
我认为使用 @ManyToMany
或 @OneToMany
足以完成您的任务
@Entity
public class Schedule extends PersistentObject implements Comparable<Schedule> {
@Column
private String title;
@ManyToOne
private Agent target;
@OneToMany
private List<Unit> units = new List<>();
}
@Entity
public class Unit {
@ManyToMany
private List<Role> assignedRoles = new List<>();
}