日期:2014-05-17  浏览次数:20863 次

SSH整合时候,使用集合出错
问题已经定位到,使用set集合就出错。当我把代码里面的Set<ReplyPO>  replys = new HashSet<ReplyPO>()注释掉之后,正常。貌似hibernate自定义的collection与jdk的冲突?求大神分析下


java.lang.NoSuchMethodError: java.util.Collections.emptyIterator()Ljava/util/Iterator;
org.hibernate.mapping.Collection.getColumnIterator(Collection.java:370)
org.hibernate.mapping.Property.getColumnIterator(Property.java:91)
org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:718)
org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:740)
org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:493)
org.hibernate.mapping.RootClass.validate(RootClass.java:271)
org.hibernate.cfg.Configuration.validate(Configuration.java:1309)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1798)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1877)


private Long articleNum;
private String category;
private String title;
private int count;
private Set<ReplyPO>  replys = new HashSet<ReplyPO>();

@Id
@SequenceGenerator(sequenceName="ARTICLE_SEQ", name="article", allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="article")
@Column(name="ARTICLE_NUM", nullable=false)
public Long getArticleNum() {
return articleNum;
}
public void setArticleNum(Long articleNum) {
this.articleNum = articleNum;
}

@Column(name="CATEGORY", nullable=false)
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}

@Column(name="TITLE", nullable=false)
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}

@Column(name="COUNT", nullable=false)
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}

@OneToMany(mappedBy="articleNum")
public java.util.Set<ReplyPO> getReplys() {
return replys;
}
public void setReplys(java.util.Set<ReplyPO> replys) {
this.replys = replys;
}

SSH 集合

------解决方案--------------------
java.util.Set<ReplyPO>都像这样写。。
------解决方案--------------------
看你引用的是哪个set
------解决方案--------------------
配置错了把?
------解决方案--------------------
应该引用util 里面的set
------解决方案--------------------
请参考我的基于spring,security的开源项目
http://blog.csdn.net/shadowsick