amartin
amartin

Reputation: 71

Migration of an Spring, Hibernate 3.6.3-JPA application to Hibernate 4

Hello I'm trying to migrate an Hibernate 3.6.3 application to Hibernate 4 and I'm getting following error:

 Invalid property 'dataSource' of bean class 
 [org.springframework.orm.jpa.LocalEntityManagerFactoryBean]: 
 Bean property 'dataSource' is not writable or has an invalid 
 setter method. Does the parameter type of the setter match the 
 return type of the getter?

I have looked a this post: integrating JPA and SpringIOc

When I use LocalEntityManagerFactoryBean I get the error mentioned above, but when I use LocalContainerEntityManagerFactoryBean I get an error when creating my DAO bean.

I think it's a problem of spring.orm dependency configuration, but I'm not sure, since all the dependency changes I have made aren't working.

Where can I find a Hibernate 4 migration guide in order to adapt my JPA, Hibernate 3.6.3 and Spring application?

Upvotes: 0

Views: 1021

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

According to the Documentation

This EntityManagerFactory bootstrap is appropriate for standalone applications which solely use JPA for data access. If you want to set up your persistence provider for an external DataSource and/or for global transactions which span multiple resources, you will need to either deploy it into a full Java EE 5 application server and access the deployed EntityManagerFactory via JNDI, or use Spring's LocalContainerEntityManagerFactoryBean with appropriate configuration for local setup according to JPA's container contract.

Which means you may have to use LocalContainerEntityManagerFactoryBean instead of LocalEntityManagerFactoryBean

<bean id="entityManager" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="myDataSource" />
    ....
    ....
</bean>

Ex:

Upvotes: 2

Related Questions