高分求解,spring+hibbernate不执行更新能查询

bunrise 2009-09-02 12:48:14
2009-09-02 12:44:47,953 INFO [org.hibernate.cfg.SettingsFactory] - Echoing all SQL to stdout
2009-09-02 12:44:47,953 INFO [org.hibernate.cfg.SettingsFactory] - Statistics: disabled
2009-09-02 12:44:47,953 INFO [org.hibernate.cfg.SettingsFactory] - Deleted entity synthetic identifier rollback: disabled
2009-09-02 12:44:47,953 INFO [org.hibernate.cfg.SettingsFactory] - Default entity-mode: pojo
2009-09-02 12:44:47,953 INFO [org.hibernate.cfg.SettingsFactory] - Named query checking : enabled
2009-09-02 12:44:47,984 INFO [org.hibernate.impl.SessionFactoryImpl] - building session factory
2009-09-02 12:44:48,359 INFO [org.hibernate.impl.SessionFactoryObjectFactory] - Not binding factory to JNDI, no JNDI name configured
2009-09-02 12:44:48,515 INFO [org.springframework.orm.hibernate3.HibernateTransactionManager] - Using DataSource [org.apache.commons.dbcp.BasicDataSource@1d6fbb3] of Hibernate SessionFactory for HibernateTransactionManager
2009-09-02 12:44:48,703 INFO [com.stsoft.examonline.test] - Began transaction (1): transaction manager [org.springframework.orm.hibernate3.HibernateTransactionManager@15fb38]; default rollback = true
Hibernate: select SEQ_EMP.nextval from dual
2009-09-02 12:44:48,890 INFO [com.stsoft.examonline.test] - Rolled back transaction after test execution
2009-09-02 12:44:48,890 INFO [org.springframework.context.support.GenericApplicationContext] - Closing org.springframework.context.support.GenericApplicationContext@18e3e60: display name [org.springframework.context.support.GenericApplicationContext@18e3e60]; startup date [Wed Sep 02 12:44:46 CST 2009]; root of context hierarchy
2009-09-02 12:44:48,890 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12a3722: defining beans [propertyConfigurer,dataSource,sessionFactory,baseHibernateDao,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#1,employeeDao,employeeService]; root of factory hierarchy
2009-09-02 12:44:48,890 INFO [org.springframework.orm.hibernate3.LocalSessionFactoryBean] - Closing Hibernate SessionFactory
2009-09-02 12:44:48,890 INFO [org.hibernate.impl.SessionFactoryImpl] - closing


hibernate能查询,我执行过查询语句,
不能更新和插入
如上,插入时都能去查序列,却没有执行更新
...全文
141 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
imasmallbird 2009-09-02
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 lxd520123 的回复:]
public abstract class BaseTestCase extends
AbstractTransactionalDataSourceSpringContextTests
这是测试类,
我直接跟踪到了DAO,他执行到了最后语句
就是数据哭没反应,也没打印出插入语句
搞半天不知道哪回事
[/Quote]
你还没得到答案结什么贴呀??
就是由于你继承了这个类导致的,你可以搜一下这个类的作用,他就是操作完数据库后,自动将操作的东西清除~~
bunrise 2009-09-02
  • 打赏
  • 举报
回复
public abstract class BaseTestCase extends
AbstractTransactionalDataSourceSpringContextTests
这是测试类,
我直接跟踪到了DAO,他执行到了最后语句
就是数据哭没反应,也没打印出插入语句
搞半天不知道哪回事
imasmallbird 2009-09-02
  • 打赏
  • 举报
回复
你打个断点跟一下,别光看日志,你可以在执行插入或更新的那一行设置,然后看看是不是执行了这句,
执行完这句去库里看一下,是不是有数据~~

还有就是有代码中没有用AbstractTransactionalDataSourceSpringContextTests这种东西对数据库操作进行测试?
bunrise 2009-09-02
  • 打赏
  • 举报
回复
就是这里我没弄明白,我事物配置文件这样的:

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<aop:config>
<aop:advisor pointcut="execution(* com.stsoft.examonline.service..*.*(..))"
advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="create*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>

我也不知道怎么默认就回滚了
老紫竹 2009-09-02
  • 打赏
  • 举报
回复
default rollback = true

这个是怎么回事,呵呵呵!你设置数据必须回滚啊!
老紫竹 2009-09-02
  • 打赏
  • 举报
回复
Rolled back transaction after test execution

事务回滚了

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧