[main] DEBUG org.springframework.context.support.FileSystemXmlApplicationContext - Publishing event in org.springframework.context.support.FileSystemXmlApplicationContext@35960f05: org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.FileSystemXmlApplicationContext@35960f05: startup date [Tue Oct 07 01:19:29 CST 2014]; root of context hierarchy]
[main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'CustomerDAO'
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [dao.daoImpl.CustomerDAO.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@e56c3cf] for Hibernate transaction
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@e56c3cf]
[main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Bound value [org.springframework.orm.hibernate3.SessionHolder@47875da7] for key [org.hibernate.impl.SessionFactoryImpl@3b5ad1da] to thread [main]
[main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Initializing transaction synchronization
[main] DEBUG org.springframework.transaction.interceptor.TransactionInterceptor - Getting transaction for [dao.daoImpl.CustomerDAO.save]
[main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@47875da7] for key [org.hibernate.impl.SessionFactoryImpl@3b5ad1da] bound to thread [main]
[main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@47875da7] for key [org.hibernate.impl.SessionFactoryImpl@3b5ad1da] bound to thread [main]
[main] DEBUG org.springframework.orm.hibernate3.HibernateTemplate - Found thread-bound Session for HibernateTemplate
Hibernate: select max(customer_id) from customer
[main] DEBUG org.springframework.orm.hibernate3.HibernateTemplate - Not closing pre-bound Hibernate Session after HibernateTemplate
[main] DEBUG org.springframework.transaction.interceptor.TransactionInterceptor - Completing transaction for [dao.daoImpl.CustomerDAO.save]
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@e56c3cf]
Hibernate: insert into test.customer (cname, password, sex, Born_date, school, subject, Origin_address, class, cellphone, email, photo, certificate, Student_id, Nick_name, Hunt_state, Work_limit, mydate, customer_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
[main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Clearing transaction synchronization
[main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager - Removed value [org.springframework.orm.hibernate3.SessionHolder@47875da7] for key [org.hibernate.impl.SessionFactoryImpl@3b5ad1da] from thread [main]
[main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@e56c3cf] after transaction
[main] DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils - Closing Hibernate Session
save ok
大半夜,收获就是对接口的另一大必要作用又有了深入理解
查了一个晚上“为什么SRPING+HIBERNATE进行SQL插入时成功,数据库没有成功”
明明知道很可能是事务没有提交,可是还想找其他原因
最终还是说服自己试试提交事务,但是发现如果提交事务用到了代理
一旦用到了代理spring上下文ac.getBean()得到的就不是纯粹的POJO了而一个sun.proxy.$Proxy11
一看又是动态代理
强制转化不了啊····
纠结了半天··该怎么办
悟出的结论:接口是所有类的【外表】。。。父类是所有类的【内在】
【代理】托管了【父类】,但是【外表】是不会变的
所有可以把【代理】的【接口】强制性“暴露”(强制性转化)出来
ApplicationContext ac = new FileSystemXmlApplicationContext("src/applicationContext.xml");
customerDao=(customerDaoImpl)ac.getBean("CustomerDAO");
完成任务@
相关文章
- 已创建了一个包含学生学号、身高、性别的学生身高信息表并输出到屏幕,学生信息从文件读取。 编写一个函数 void reverse(Seqlist *lp); 功能是对已建立的学生身
- 相机参数(焦距)初始化对三维重建过程的影响
- 在Unity中对注册表的信息进行操作
- c#接口容易被忽视的问题
- SpringBoot+责任链模式:优雅的实现复杂接口的解耦和动态编排!-三、代码
- VS2010对C++11的支持列表(感觉大部分都不支持)
- 对foreach循环的思考
- Oracle-left join两表关联只取B表匹配到的第一条记录【over partition by(分组后对组内数据排序)】
- 调用获取学生信息的接口,保存到excel里面的小程序
- SQL Server中如何设置对列的权限