我正在尝试根据Jersey/Jaxb 上的接受的答案在 Artcile 的评论列表周围添加一个包装类,为豆类列表起别名
public class Article implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
...
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "ARTICLE_COMMENT",
joinColumns =
{
@JoinColumn(name = "ARTICLE_ID", referencedColumnName = "ID")
},
inverseJoinColumns =
{
@JoinColumn(name = "COMMENT_ID", referencedColumnName = "ID")
})
@XmlElementWrapper(name = "user_comments")
private List<Comment> comments;
public Article()
{
}
...
}
而评论是
@XmlRootElement
@Entity
public class Comment implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
/*
@ManyToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER)
private Collection<Article> articles;
*/
...
}
但是它返回此错误
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Klasse enthält zwei Eigenschaften mit demselben Namen "comments"
将 Collection 更改为 List of comments 并没有太大变化。有人知道我能做什么吗?