-
Sep 5th, 2007, 01:24 AM
#11
sure, thanx dude.give me the dao and app-context file.
-
Sep 7th, 2007, 04:59 AM
#12
Hi. here's the important part from the app context xml:
<code>
<tx:annotation-driven />
<bean id="persistenceUnitManager"
class="org.springframework.orm.jpa.persistenceunit .DefaultPersistenceUnitManager">
<property name="persistenceXmlLocations">
<list>
<value>classpath
ersistence.xml</value>
</list>
</property>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
<property name="persistenceUnitManager"
ref="persistenceUnitManager" />
<property name="persistenceUnitName"
value="persistence-unit-name" />
</bean>
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionM anager">
<property name="entityManagerFactory"
ref="entityManagerFactory" />
</bean>
<bean
class="org.springframework.orm.jpa.support.Persist enceAnnotationBeanPostProcessor" />
</code>
And the DAO is an ordinary class. The only thing is that it has @Transactional
Hope it helps.
-
Sep 8th, 2007, 12:19 PM
#13
Very important!!! Make sure you put <tx:annotation-driven/> in your xml file! Otherwise, the @Transactional will be in vain.
-
Nov 16th, 2007, 04:36 PM
#14
Any solution to the above problem
I have the very same problem...
-
Nov 20th, 2007, 04:29 PM
#15
Use Annotation Driven Transaction Manager
Try using the following approach...
<bean
class="org.springframework.orm.jpa.support.Persist enceAnnotationBeanPostProcessor" />
<bean id="catalogService"
class="com.mobchannel.store.catalog.service.Catalo gServiceImpl"
scope="singleton" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>${mobchannel.database.uri}</value>
</property>
<property name="username">
<value>${mobchannel.database.user.username}</value>
</property>
<!-- Make sure <value> tags are on same line - if they're not,
authentication will fail -->
<property name="password">
<value>${mobchannel.database.user.password}</value>
</property>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
<property name="database" value="MYSQL" />
<property name="showSql">
<value>${mobchannel.hibernate.showsql}</value>
</property>
</bean>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionM anager">
<property name="entityManagerFactory"
ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules