简体   繁体   English

使用@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

I have two tables NewsToolSearchCriteria and NewsToolSearchCriteria_NewsSource_Relation . 我有两个表NewsToolSearchCriteriaNewsToolSearchCriteria_NewsSource_Relation newsToolSearchCriteriaId is the foreign key references to NewsToolSearchCriteria (entityID) I want to see a set of elements from the second table inside first. newsToolSearchCriteriaId是对NewsToolSearchCriteria (entityID) newsToolSearchCriteriaId )的外键引用,我想从第二个表中首先看到一组元素。

Trying to set it up this way: 尝试通过以下方式进行设置:

@ElementCollection
@CollectionTable(name = "NewsToolSearchCriteria_NewsSource_Relation", joinColumns = @JoinColumn(name = "newsToolSearchCriteriaId"))
@Column(name = "newsSourceCode")
private Set<String> newsSources;

public Set<String> getNewsSources() {
    return newsSources;
}

public void setNewsSources(Set<String> newsSources) {
    this.newsSources = newsSources;
}

But keep receiving the error: 但是继续收到错误:

nested exception is org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: dbo.NewsToolSearchCriteria, for columns: [org.hibernate.mapping.Column(newsSources)] 嵌套的异常是org.hibernate.MappingException:无法确定类型:java.util.Set,在表:dbo.NewsToolSearchCriteria,对于列:[org.hibernate.mapping.Column(newsSources)]

I've already tried to use @Column(name = "newsSourceCode", columnDefinition = "NVARCHAR(30)") and @ElementCollection(targetClass = String.class) 我已经尝试使用@Column(name = "newsSourceCode", columnDefinition = "NVARCHAR(30)")@ElementCollection(targetClass = String.class)

I already saw other similar questions but it is not the case where I using two entities and it could be resolved using @OneToMany . 我已经看到了其他类似的问题,但不是使用两个实体的情况,可以使用@OneToMany来解决。

Any ideas how to resolve this issue? 任何想法如何解决这个问题?

You just have to add annotations on getter instead of a class parameter. 您只需要在getter上添加注释,而不是类参数即可。

I did not find the place where it said, but they use it in documentation and it works for me. 我没有找到它说的地方,但他们在文档中使用了它,对我有用。

暂无
暂无

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

相关问题 获取 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 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 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)] hibernate MappingException:无法确定类型:java.util.Set - hibernate MappingException: Could not determine type for: java.util.Set 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.Collection,用于列:[org.hibernate.mapping.Column(lisOfAddresses)] - org.hibernate.MappingException: Could not determine type for: java.util.Collection, for columns: [org.hibernate.mapping.Column(lisOfAddresses)] org.hibernate.MappingException:无法确定以下类型:java.util.Comparator - org.hibernate.MappingException: Could not determine type for: java.util.Comparator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM