0

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.

jam
  • 3,640
  • 5
  • 34
  • 50
user1879835
  • 71
  • 4
  • 7
  • It seems that [here](http://stackoverflow.com/questions/4530572/org-hibernate-mappingexception-unknown-entity) they have already solved the problem – Xstian Aug 12 '14 at 12:43
  • A related question: [java - How to save multiple objects via ArrayList in hibernate?](https://stackoverflow.com/questions/38923108/how-to-save-multiple-objects-via-arraylist-in-hibernate). – Sergey Vyacheslavovich Brunov Jan 29 '22 at 16:30

1 Answers1

2

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

Community
  • 1
  • 1
Maas
  • 1,317
  • 9
  • 20