hibernate 单实体实现 一对多
访问时jsp页面的错误:org.springframework.dao.InvalidDataAccessResourceUsageException: could not initialize a collection
?
原因:???? <set name="childrens" inverse="true"? lazy="false" where="parentFunction=S_FUNCTION_ID">
??????? ?<key>
??????????????? <column name="S_FUNCTION_ID" />
??????????? </key>
??????????? <one-to-many />
??????? </set>
?
注:parentFunction应该为列明
?
正确的为:
? <set name="childrens" inverse="true"? lazy="false" where="PARENT_FUNCTION=S_FUNCTION_ID">
??????? ?<key>
??????????????? <column name="S_FUNCTION_ID" />
??????????? </key>
??????????? <one-to-many />
??????? </set>
?
实体中对应的代码:
private Set<SFunction> childrens =new HashSet<SFunction>(0);
???????
?