简体   繁体   English

获取 org.hibernate.MappingException:无法确定类型:java.util.Set,在表:使用@ElementCollection 后的作者

[英]Getting a org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: Authors after using @ElementCollection

I am trying to persist collection of string for an Entity.我正在尝试为实体保留字符串集合。 To be more specific here is my Entity:更具体地说,这里是我的实体:

@Entity
@Table(name = "AUTHOR")
public class Author{
   //Other fields associated with author
   @ElementCollection
   @CollectionTable(name = "AUTHOR_PHONE_NUMBER", joinColumns = @JoinColumn(name = "author_id"))
   @Column(name="phone_number")
   private Set<String> phoneNumbers;

  //Constructors
  //Getters & Setters

}

However, when I build and run the code, I am getting following exceptions:但是,当我构建并运行代码时,出现以下异常:

Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: AUTHOR for columns: [org.hibernate.mapping.Column(phone_number)]

I am seeing many questions similar to this on this platform but all those involve OneToMany mapping to persist collections.我在这个平台上看到许多与此类似的问题,但所有这些问题都涉及 OneToMany 映射以持久化 collections。

The list phoneNumbers should be @OneToMany , @ManyToMany (this depends from AUTHOR_PHONE_NUMBER table) annotation, replacing @CollectionTable.列表 phoneNumbers 应该是@OneToMany@ManyToMany (这取决于 AUTHOR_PHONE_NUMBER 表)注释,替换 @CollectionTable。

the configuration must be same with @JoinColumn annotation.配置必须与@JoinColumn注释相同。

暂无
暂无

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

相关问题 使用@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.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)] 无法构建 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:无法确定以下类型:java.util.Set - many to many relationship : org.hibernate.MappingException: Could not determine type for: java.util.Set hibernate MappingException:无法确定类型:java.util.Set - hibernate MappingException: Could not determine type for: java.util.Set 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.List,在表:Schedule_assignedRoles,对于列:AssignedRoles - org.hibernate.MappingException: Could not determine type for: java.util.List, at table: Schedule_assignedRoles, for columns: assignedRoles org.hibernate.MappingException:无法确定以下类型:java.util.Comparator - org.hibernate.MappingException: Could not determine type for: java.util.Comparator org.hibernate.MappingException:无法确定以下类型: - org.hibernate.MappingException: Could not determine type for:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM