开发者

entitymanager.merge does not seem to commit

I have an application using Tomcat/Spring 3/JPA/Hibernate but my merges do not commit to datbase. This is the configuration:

spring-conf.xml:

 <bean id="dataSource"
  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  <property name="url" value="jdbc:mysql://localhost/.." />
  <property name="username" value=".." />
  <property name="password" value=".." />
 </bean>

 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
   <property name="entityManagerFactory" ref="entityManagerFactory"/>
 </bean>

 <tx:annotation-driven transaction-manager="transactionManager"/>

<context:annotation-config/>


 <bean id="entityManagerFactory"
  class="org.springframework.orm.jpa.LocalC开发者_开发问答ontainerEntityManagerFactoryBean">
  <property name="dataSource" ref="dataSource" />
 </bean>

persistence.xml:

<persistence-unit name=".." transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
    ...
<property name="dialect" value="org.hibernate.dialect.MySQLDialect" />

and this is a simple class:

@Transactional
public class UserAdServiceImpl{
...    
merge(...);

any idea?


my bad! i was trying to merge an entity which was the result of a read-only query so i was unable to alter that !!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜