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.

2

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.