日期:2014-05-20 浏览次数:20948 次
org.springframework.orm.hibernate3.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:679)
    String hql="from Roles where id in(";
        for(int i=0;i<roles.length-1;i++)
        {
            hql+=roles[i]+",";
        }
        hql+=roles[roles.length-1]+")";
        this.getHibernateTemplate().clear();
        this.getHibernateTemplate().flush();
        List<Roles> list=this.getHibernateTemplate().find(hql);
        this.getHibernateTemplate().deleteAll(list);
    <filter>
        <filter-name>openSessionInViewFilter</filter-name>
        <filter-class>
            org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
        <init-param>
            <param-name>singleSession</param-name>
            <param-value>false</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>openSessionInViewFilter</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>