关于Hibernate3.2的疑问。

对于动态模型,我定义了个双向一对多关联。
这个是一对象的XML描述
[code="java"]
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">






























    </set>  

</class> 

[/code]
这个是多对象的XML描述
[code="java"]
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">













<many-to-one name="SystemTree" class="SystemTree" fetch="select">   
        <column name="SystemTree_id" />   
</many-to-one>   

</class> 


[/code]

这个是访问的代码:
[code="java"]
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
StandardDAO dao = (StandardDAO)ctx.getBean("StandardDAO");
Integer ID;

ID = Integer.valueOf(request.getParameter("id"));
List tree = dao.findBySQL("from SystemTree where ID=" + ID);
Map map = (Map)tree.get(0);

    List ls = (List)map.get("childs");      

[/code]
现在是访问childs时候出现:
java.lang.ClassCastException: org.hibernate.collection.PersistentSet;

[color=red]List ls = (List)map.get("childs");[/color] 就是段代码有问题,难道动态模型不能定义关联关系???

hibernate内部实现是用org.hibernate.collection.PersistentSet集合类的,
所以不能List ls = (List)map.get("childs"); 这么转换成jdk的集合类

类型转换异常
map.get("childs")返回的肯定不是List.

类型转换异常

可以用String s=(String)map.get("childs");

List ls = (List)map.get("childs");强制 转换异常
map.get("childs")得到的是一个Set集合,不能这样转换哦

Map map = (Map)tree.get(0);  

这一句有问题吧,是Map对象吗?