struts+spring+hibernate 读取数据库可以,写入数据库不成功,高手指点一下... 正解如果没有配全局的事物你必须为每个insert update delete 做一次显式的提交 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的DAO层是继承自HibernateDaoSupport,这个类没有实现事务的自动提交吗?如果没有, 假如我在spring配置文件applicationContext.xml中采用的是声明式的事务处理方式,如下:<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="userDaoProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref bean="transactionManager"/> </property> <property name="proxyInterfaces"> <list> <value>com.jk.IUserDao</value> </list> </property> <property name="target"> <list> <ref bean="userDao"/> </list> </property> <property name="transactionAttributes"> <props> <prop key="insert*">PROPAGATION_REQUIRED</prop> </props> </property> </bean>这样的话,我如何在struts的action中应用这个事务代理呢?是采用setter和getter的方式让spring自动注入一个吗?还是采用如下的方式调用?ApplicationContext context=new ClassPathXmlApplicationContext("***")IUserDao userDao=(IUserDao)context.getBean("userDaoProxy");useDao.save(***)两种我都试过了,都不行,是不是我哪里写错了?请前辈们指点一下........ 你测试一下在你的BBuser里面有值吗 是否主键已经存在 或是没有值如果没有问题 那就是食物的问题你在事务中在吧BBuser的hbm.xml的配置加上 bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="eventListeners"> <map> <entry key="post-update"> <ref local="historyListener"/> </entry> </map> </property> <property name="mappingDirectoryLocations"> <list> <value>classpath*:/com/cnc/combine/plugins/menu/domain/hbm/</value> <value>classpath*:/com/cnc/combine/plugins/security/domain/hbm/</value> <value>classpath*:/com/cnc/oa/domain/hbm/</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop> </props> </property> </bean>你参照下 试试 请问关于用JAVA实现的数据采集 很纠结的问题 各位大师帮帮忙 查询后分页 java 反序列化的问题 总也编译不了jsp,好像是配置的问题,那位仁兄帮帮忙。 java中如何实现按队列执行任务? *******JTable刷新问题*****^^来者给分 请问!JBUILDER X下配置struts1.1的DataSource数据源详细配置方法 【求助和讨论】J2EE可以用来做电信计费吗? 非常着急的问题,<html:text 里死活从action bean里取不出值来,我要疯了~~~ 请教高weblogic+myeclipse下调试JSP的使用问题
如下:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="userDaoProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="proxyInterfaces">
<list>
<value>com.jk.IUserDao</value>
</list>
</property>
<property name="target">
<list>
<ref bean="userDao"/>
</list>
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>这样的话,我如何在struts的action中应用这个事务代理呢?
是采用setter和getter的方式让spring自动注入一个吗?还是采用如下的方式调用?
ApplicationContext context=new ClassPathXmlApplicationContext("***")
IUserDao userDao=(IUserDao)context.getBean("userDaoProxy");
useDao.save(***)两种我都试过了,都不行,是不是我哪里写错了?
请前辈们指点一下........
在你的BBuser里面有值吗 是否主键已经存在 或是没有值
如果没有问题 那就是食物的问题你在事务中在吧BBuser的hbm.xml的配置加上
<property name="dataSource" ref="dataSource"/>
<property name="eventListeners">
<map>
<entry key="post-update">
<ref local="historyListener"/>
</entry>
</map>
</property> <property name="mappingDirectoryLocations">
<list>
<value>classpath*:/com/cnc/combine/plugins/menu/domain/hbm/</value>
<value>classpath*:/com/cnc/combine/plugins/security/domain/hbm/</value>
<value>classpath*:/com/cnc/oa/domain/hbm/</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
</props>
</property>
</bean>
你参照下 试试