简体   繁体   English

org.hibernate.MappingException:无法确定类型:java.util.List,在表:Schedule_assignedRoles,对于列:AssignedRoles

[英]org.hibernate.MappingException: Could not determine type for: java.util.List, at table: Schedule_assignedRoles, for columns: assignedRoles

I need a help, I'm trying to use a Map, but I got this error: 我需要帮助,我正在尝试使用地图,但出现此错误:

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) 原因:org.hibernate.MappingException:无法确定类型:java.util.List,在表:Schedule_assignedRoles,对于列:[org.hibernate.mapping.Column(assignedRoles)]在org.hibernate.mapping.SimpleValue。 org.hibernate.mapping.IndexedCollection上的getType(SimpleValue.java:390)在org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:363)在org.hibernate.mapping.Collection.validate(Collection.java:310) org.org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:333)的.validate(IndexedCollection.java:74)org.org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443)的.validate(IndexedCollection.java:74) hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802)

here my code: 这是我的代码:

@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
}

thank's! 谢谢! :D :D

I think using @ManyToMany or @OneToMany is enough for your task 我认为使用@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<>();

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.hibernate.MappingException:无法确定类型:java.util.List,在表:大学,列:[org.hibernate.mapping.Column(students)] - org.hibernate.MappingException: Could not determine type for: java.util.List, at table: College, for columns: [org.hibernate.mapping.Column(students)] org.hibernate.MappingException:无法确定类型:java.util.List,在表:user处,用于列:[org.hibernate.mapping.Column(events)] - org.hibernate.MappingException: Could not determine type for: java.util.List, at table: user, for columns: [org.hibernate.mapping.Column(events)] org.hibernate.MappingException:无法确定类型:java.util.Set,在表:Company中,用于列:[org.hibernate.mapping.Column(users)] - org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: Company, for columns: [org.hibernate.mapping.Column(users)] 使用@ElementCollection时出错:org.hibernate.MappingException:无法确定类型:java.util.Set,在表:对于列 - Error while using @ElementCollection: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: for columns org.hibernate.MappingException:无法确定类型:java.util.Collection,用于列:[org.hibernate.mapping.Column(lisOfAddresses)] - org.hibernate.MappingException: Could not determine type for: java.util.Collection, for columns: [org.hibernate.mapping.Column(lisOfAddresses)] 无法构建 Hibernate SessionFactory; 嵌套异常是 org.hibernate.MappingException:无法确定类型:java.util.Set,在表中: - Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: org.hibernate.MappingException:无法确定以下类型:表:对于列:[org.hibernate.mapping.Column(plant) - org.hibernate.MappingException: Could not determine type for: at table: for columns: [org.hibernate.mapping.Column(plant) org.hibernate.MappingException:无法确定以下类型:java.util.Comparator - org.hibernate.MappingException: Could not determine type for: java.util.Comparator 多对多关系:org.hibernate.MappingException:无法确定以下类型:java.util.Set - many to many relationship : org.hibernate.MappingException: Could not determine type for: java.util.Set org.hibernate.MappingException:无法确定以下类型: - org.hibernate.MappingException: Could not determine type for:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM