0
votes

I've recently upgraded hibernate version from 3.0 to 4.0 and most of the things were working fine except when I tried to save list of entities. If I save each entity separately I'm not getting any exception but when I try to save the entire list, getting the following exception:

org.springframework.orm.hibernate4.HibernateSystemException: Unknown entity: java.util.ArrayList; nested exception is org.hibernate.MappingException: Unknown entity: java.util.ArrayList

code:

this.getHibernateTemplate().saveOrUpdate(entityObject) // Results in exception

Session configuration:

<bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="packagesToScan" value="domain">
        </property>

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.dialect">${jdbc.dialect}</prop>
            </props>
        </property>
    </bean>

Your help is appreciated.

1
It seems that here they have already solved the problem - Xstian

1 Answers

2
votes

You cannot pass a collection of objects to the session object for persisting. As per the Session javadoc, the save accepts a Object of the persistent class

see if this answer helps you : Hibernate saveOrUpdate large data