關于在Spring中如何統一控制Hibernate和JDBC的事務的討論記錄
?Totodo(888669) 13:17:17
HB 和 JDBC 同一個事務?
水木-Spring(3330309) 13:17:40
jdbc也是有事務的.
水木-Spring(3330309) 13:17:54
hibernate只不過封裝呢jdbc的事務而已
水木-Spring(3330309) 13:19:01
同一個數據源?
Water Ye(54422686) 13:19:56
同一個connection的話, 這樣應該可以
t.beginTransaction();
a.method();
b.method();
t.commit();
?Totodo(888669) 13:21:14
是滴,這個比較頭疼..
?Totodo(888669) 13:21:35
我們后來是傳 session,然后session.getConnection.
水木-Spring(3330309) 13:22:19
如果是session.getConnection那就是同一個connection了
xxxxxxx(12345678) 13:25:24
其實我并不知道他們是怎么搞得,我覺得應該不同connection,因為只有我用了Hibernate,其他模塊都沒用,怎么可能同一個connection阿,頭痛!
水木-Spring(3330309) 13:24:12
這個是非常麻煩的,即使使用jta都是很麻煩,因為沒有spring這樣的事務配置管理,jta的事務代碼需要自己寫.麻煩啊
?Totodo(888669) 13:24:41
? 嘻嘻,我們現在最好的業務系統模型,,基于存儲過程架構的.dao只是查查數據而已..
水木-Spring(3330309) 13:24:55
這個事前沒有約定一些規則.怎么會出現這種情況?
xxxxxxx(12345678) 13:28:17
ok,假如我在HB里面用他們的connection,行不行?
水木-Spring(3330309) 13:26:16
這個說的就不專業了,大俠給說說,你怎么用他們的connection?
水木-Spring(3330309) 13:26:27
讓俺學習學習.
xxxxxxx(12345678) 13:29:42
我不知道,我極少涉及到事務
?Totodo(888669) 13:27:14
? SessionFactroy 用的是datasource .大哥..
水木-Spring(3330309) 13:27:18
hibernate里的connection是sessionFactory產生出來的,你能用jdbc的連接,厲害.
水木-Spring(3330309) 13:27:43
跟事務是兩回事啊.
xxxxxxx(12345678) 13:30:38
就是嘛,我就是這個意思
水木-Spring(3330309) 13:28:12
如果你說,jdbc用你session里產生的connection,我還覺的說的過去.
xxxxxxx(12345678) 13:30:54
我想知道怎么解決jdbc跟hb的事物
水木-Spring(3330309) 13:28:31
兩種方法
xxxxxxx(12345678) 13:31:12
這是我的代碼
???Configuration config = new Configuration().configure();
???SessionFactory sf = config.buildSessionFactory();
???s = sf.openSession();
???Transaction tx = s.beginTransaction();
???Criteria cr = s.createCriteria(TSign.class);
xxxxxxx(12345678) 13:31:42
哦?你覺得在哪一邊改動比較好?
水木-Spring(3330309) 13:29:27
哦?首先問你個問題,你的代碼怎么和別人的代碼交互的?
?Totodo(888669) 13:30:11
好久沒看到這樣的代碼了
Configuration ,Sf,Transaction 都能看到..
水木-Spring(3330309) 13:30:25
在你的代碼里調用別人的代碼?
水木-Spring(3330309) 13:31:07
準確的說,Configuration ,Sf這樣的代碼確實比較少見了.
水木-Spring(3330309) 13:31:25
如果不使用spring的話,Transaction是必不可少的.
xxxxxxx(12345678) 13:34:23
別人Call我的
水木-Spring(3330309) 13:31:59
話說回來,david.turing你這段代碼本身就有問題的.
水木-Spring(3330309) 13:32:08
應該說效率很低的.
xxxxxxx(12345678) 13:34:48
這些代碼是Workshop生成的?
水木-Spring(3330309) 13:33:11
恐怖的代碼生成器啊
xxxxxxx(12345678) 13:36:14
帥哥,你的思路如何,讓我借鑒一下
xxxxxxx(12345678) 13:36:42
我那時候沒有用JDBCTemplate,真是一個事物
xxxxxxx(12345678) 13:36:48
失誤
水木-Spring(3330309) 13:34:57
no,no,即使你沒用spring里的jdbcTemplate你的這段代碼也大有問題的,你自己上網查查看.
水木-Spring(3330309) 13:35:03
說一下你剛才的事務的問題.
xxxxxxx(12345678) 13:38:11
恩,把問題先解決
?Totodo(888669) 13:35:34
?我的原則不把在tx寫代碼里..
不過代碼都這樣寫,就沒關系了..
帶著參數互相傳吧..
水木-Spring(3330309) 13:36:30
我假設你的代碼(hibernate)里調用別人(jdbc),那么你可以將session里產生的connection當作參數傳遞給jdbc的程序.當然,事務最終在你這里做統一提交.
水木-Spring(3330309) 13:36:47
但這種情況不好的地方就是需要是同一個connection
xxxxxxx(12345678) 13:40:18
如果是別人調用我的HB呢?
水木-Spring(3330309) 13:37:41
第二種方法就是使用jta,這種情況的好處是不僅連接可以不是同一個,數據源也可以不一樣.
xxxxxxx(12345678) 13:40:33
jta,復雜否?
水木-Spring(3330309) 13:38:00
如果別人調用你的,你就暈吧.
水木-Spring(3330309) 13:39:14
jta?是否復雜,兩方面,首先你的的應用服務器是什么?然后你時候使用spring這樣的形式來管理事務.
xxxxxxx(12345678) 13:43:35
weblogic 8.1
xxxxxxx(12345678) 13:43:44
沒用用Spring
getdown(9486681) 13:41:19
現在用Spring吧...
水木-Spring(3330309) 13:41:29
呵呵,晚了.
xxxxxxx(12345678) 13:44:09
暈倒
getdown(9486681) 13:41:46
不會晚
水木-Spring(3330309) 13:41:55
應用服務器一般都實現很好的jta
getdown(9486681) 13:41:59
原來事務代碼還保存沒有關系..
xxxxxxx(12345678) 13:44:43
帥哥們,我是不想負這個責任
netfishx(151431) 13:42:31
對,不是說換就換的啊
xxxxxxx(12345678) 13:45:16
JTA能解決跨Connection的問題?
getdown(9486681) 13:42:38
不用換啊..
getdown(9486681) 13:42:43
JTA可以..
getdown(9486681) 13:42:48
不過JTA有點限制
getdown(9486681) 13:43:15
我有碰到代碼里面直接寫connection.commit()...
getdown(9486681) 13:43:22
這種情況就不能用JTA了..
水木-Spring(3330309) 13:43:36
這叫什么限制啊,呵呵.
水木-Spring(3330309) 13:43:50
這是起碼的規則吧
xxxxxxx(12345678) 13:47:04
我可以改代碼啊
getdown(9486681) 13:44:03
呵呵 你不知道 原有存在的很多系統都是這么控制事務的..
水木-Spring(3330309) 13:44:27
全局事務,當然不允許你自己做提交了.呵呵.
xxxxxxx(12345678) 13:47:48
tx.commit();全部更換我都可以去做
getdown(9486681) 13:44:49
最簡單的還是用Spring的HibernateTransactionMananger來管理Hibernate和JDBC的事務一致.
xxxxxxx(12345678) 13:48:00
恩!
xxxxxxx(12345678) 13:48:27
但他們如果不用Spring呢? 工作量大不大?
getdown(9486681) 13:45:30
...
水木-Spring(3330309) 13:45:44
他們不用,你還做什么啊?暈
xxxxxxx(12345678) 13:49:07
我要創造條件給他們去用
getdown(9486681) 13:46:15
這是可行的
?Totodo(888669) 13:46:19
老實說,我不喜歡JTA...
xxxxxxx(12345678) 13:49:23
但是要我把HB->JDBC我死活不愿意的
xxxxxxx(12345678) 13:49:42
他們也不會JDBC->HB
水木-Spring(3330309) 13:46:45
其實david.turing,你的這個改造不是很麻煩的,至少你不是跨數據源的.
xxxxxxx(12345678) 13:49:53
恩....
水木-Spring(3330309) 13:47:09
但是改造的話,風險也不小的.
xxxxxxx(12345678) 13:50:11
答案,我等不及了
getdown(9486681) 13:47:14
那就用HibernateTransactionManager來管理吧,我試過,改動最小..
getdown(9486681) 13:47:17
風險也最小..
xxxxxxx(12345678) 13:50:29
JDBC?
getdown(9486681) 13:47:30
我剛剛在一個大項目的二次開發里面用
xxxxxxx(12345678) 13:50:36
強
getdown(9486681) 13:47:52
HibernateTransactionManager可以同時保證JDBC和Hibernate的事務一致..
xxxxxxx(12345678) 13:51:47
有你這句話就行了
xxxxxxx(12345678) 13:52:00
getdown,給一個配置的sample我看看如何?
getdown(9486681) 13:48:59
呵呵 這個你放心了 我很仔細的試過了..
getdown(9486681) 13:49:07
ok
xxxxxxx(12345678) 13:52:12
thx!!!
?Totodo(888669) 13:52:44
getdown(9486681) 13:44:49
最簡單的還是用Spring的HibernateTransactionMananger來管理Hibernate和JDBC的事務一致.?
getdown(9486681) 13:52:53
?
?Totodo(888669) 13:53:02
?牛了..我要學習一下.
?Totodo(888669) 13:53:54
好比Spring 我有一段這樣子配的..
?Totodo(888669) 13:53:56
?<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
?<bean id="rscTransactionControl" class="org.springframework.orm.hibernate.HibernateTransactionManager">
??<property name="sessionFactory">
???<ref local="rscSessionFactory" />
??</property>
?</bean>
?
?Totodo(888669) 13:54:40
對應的事務控制分別是..
?<bean id="txAttributes" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
??<property name="properties">
???<value>
?????*=PROPAGATION_REQUIRED
?????do*=PROPAGATION_REQUIRED
???< alue>
??</property>
?</bean>
?
?<bean id="txInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
??<property name="transactionManager">
???<ref bean="rscTransactionControl" />
??</property>
??<property name="transactionAttributeSource">
???<ref bean="txAttributes" />
??</property>
?</bean>
?Totodo(888669) 13:55:20
HB事務控制的
?<bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
??<property name="interceptorNames">
???<value>txInterceptor< alue>
??</property>
??<property name="beanNames">
???<list>
????<value>*DAO< alue>
????<value>*Manager< alue>
???< st>
??</property>
?</bean>
????
?Totodo(888669) 13:55:45
而我另外用個JDBC的..
?Totodo(888669) 13:55:49
?<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
??<constructor-arg>
???<ref bean="rscDataSource" />
??</constructor-arg>
?</bean>
?Totodo(888669) 13:56:33
JDBC 怎么被 HibernateTransactionManager, 管理上?
getdown(9486681) 13:56:44
呵呵...
getdown(9486681) 13:56:59
我發給你看看
netfishx(151431) 13:57:12
貼出來都看看嘛
getdown(9486681) 13:57:27
ok 那我就貼出來看吧..
?Totodo(888669) 13:57:28
要看哦..
getdown(9486681) 13:57:46
前面的簡單 ..先
?<bean id="baseService" lazy-init="true" abstract="true"
??class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
??<property name="transactionManager" ref="transactionManager" />
??<property name="transactionAttributes">
???<props>
????<prop key="*">PROPAGATION_REQUIRED</prop>
???</props>
??</property>
?</bean>
getdown(9486681) 13:57:59
這個等于是總的Service的配置.
?Totodo(888669) 13:58:07
er..
?Totodo(888669) 13:58:09
en ..
getdown(9486681) 13:58:33
然后 JDBC的..
?<bean id="userJdbcDao"
??class="com.gfa4j.demo.jdbc.impl.UserJdbcDaoImpl">
??<property name="dataSource">
???<ref bean="dataSource" />
??</property>
?</bean>
getdown(9486681) 13:59:09
然后是Service的...
?<bean id="userJdbcService" parent="baseService">
??<property name="target">
???<bean
????class="com.gfa4j.demo.jdbc.impl.UserJdbcServiceImpl">
????<property name="jdbcDao" ref="jdbcDao" />
???</bean>
??</property>
?</bean>
?Totodo(888669) 13:59:23
? OH....
getdown(9486681) 13:59:37
這個時候其實調用JDBC的時候等于用了HibernateTransactionMananger了..
?Totodo(888669) 14:00:35
這里的ref de transcationManager 就是 HibernateTransactionMananger 么?
getdown(9486681) 14:00:39
嗯..
getdown(9486681) 14:00:44
兩個用的都是..
?Totodo(888669) 14:00:49
天才啊..
getdown(9486681) 14:00:59
?<bean id="userHibernateService" parent="baseService">
??<property name="target">
???<bean
????class="com.gfa4j.demo.service.impl.UserHibernateServiceImpl">
????<property name="userJdbcService" ref="userJdbcService" />
???</bean>
??</property>
?</bean>
getdown(9486681) 14:01:07
這個是Hibernate Service
getdown(9486681) 14:01:14
這樣就可以很方便的調用了..
netfishx(151431) 14:01:19
這樣就可以???
getdown(9486681) 14:01:23
嗯 ...
?
?Totodo(888669) 15:29:45
看了JdbcTemplate 的源..
?Totodo(888669) 15:29:46
?//-------------------------------------------------------------------------
?// Methods dealing with static SQL (java.sql.Statement)
?//-------------------------------------------------------------------------
?public Object execute(StatementCallback action) throws DataAccessException {
??Connection con = DataSourceUtils.getConnection(getDataSource());
??Statement stmt = null;
??try {
???Connection conToUse = con;
???if (this.nativeJdbcExtractor != null &&
?????this.nativeJdbcExtractor.isNativeConnectionNecessaryForNativeStatements()) {
????conToUse = this.nativeJdbcExtractor.getNativeConnection(con);
???}
???stmt = conToUse.createStatement();
???DataSourceUtils.applyTransactionTimeout(stmt, getDataSource());
???Statement stmtToUse = stmt;
???if (this.nativeJdbcExtractor != null) {
????stmtToUse = this.nativeJdbcExtractor.getNativeStatement(stmt);
???}
???Object result = action.doInStatement(stmtToUse);
???SQLWarning warning = stmt.getWarnings();
???throwExceptionOnWarningIfNotIgnoringWarnings(warning);
???return result;
??}
??catch (SQLException ex) {
???throw getExceptionTranslator().translate("executing StatementCallback", getSql(action), ex);
??}
??finally {
???JdbcUtils.closeStatement(stmt);
???DataSourceUtils.closeConnectionIfNecessary(con, getDataSource());
??}
?}
?Totodo(888669) 15:31:42
?public static Connection doGetConnection(DataSource dataSource, boolean allowSynchronization)
???throws SQLException {
??Assert.notNull(dataSource, "No DataSource specified");
??ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
??if (conHolder != null) {
???conHolder.requested();
???return conHolder.getConnection();
??}
??logger.debug("Opening JDBC connection");
??Connection con = dataSource.getConnection();
??if (allowSynchronization && TransactionSynchronizationManager.isSynchronizationActive()) {
???logger.debug("Registering transaction synchronization for JDBC connection");
???// Use same Connection for further JDBC actions within the transaction.
???// Thread-bound object will get removed by synchronization at transaction completion.
???conHolder = new ConnectionHolder(con);
???TransactionSynchronizationManager.bindResource(dataSource, conHolder);
???TransactionSynchronizationManager.registerSynchronization(new ConnectionSynchronization(conHolder, dataSource));
???conHolder.requested();
??}
??return con;
?}
?Totodo(888669) 15:35:37
jdbc 用的是 DataSourceTransactionManager
hb 用的是 HibernateTransactionManager
?Totodo(888669) 15:39:51
It is possible--and sometimes useful--to have coordinated transactions for both. Your JDBC transactions will be managed by the HibernateTransactionManager if you work with the same JDBC DataSource in the same transaction. That is, create the SessionFactory using Spring's SessionFactoryBean using the same DataSource that your JdbcTemplates use.
The only issue to watch, of course, is that you may be invalidating your Hibernate cache by JDBC changes. Generally I find it best to use JDBC to update only tables that don't have Hibernate mappings.
It is possible--and sometimes useful--to have coordinated transactions for both. Your JDBC transactions will be managed by the HibernateTransactionManager if you work with the same JDBC DataSource in the same transaction. That is, create the SessionFactory using Spring's SessionFactoryBean using the same DataSource that your JdbcTemplates use.
The only issue to watch, of course, is that you may be invalidating your Hibernate cache by JDBC changes. Generally I find it best to use JDBC to update only tables that don't have Hibernate mappings.
?
?Totodo(888669) 15:46:14
貌似可以啊....奇怪...
?Totodo(888669) 15:47:36
sorry...騷擾了大家很久....
?Totodo(888669) 15:47:42
我還是想問下..
?Totodo(888669) 15:49:01
?<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
??<constructor-arg>
???<ref bean="rscDataSource" />
??</constructor-arg>
?</bean>
?
?<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
?<bean id="rscTransactionControl" class="org.springframework.orm.hibernate.HibernateTransactionManager">
??<property name="sessionFactory">
???<ref local="rscSessionFactory" />
??</property>
?</bean>
?<bean id="portAssignerDAO" class="bss.resourcemanager.rscass.assport.dao.impl.PortAssignerDAOImpl">
??<property name="sessionFactory">
???<ref bean="rscSessionFactory" />
??</property>
??<property name="jdbcTemplate">
???<ref bean="jdbc" />
??</property>
?</bean>
為什么我的portAssignerDAO ,用 hb ,和jdbc 不能保證再同一個事務中呢?
?Totodo(888669) 15:49:25
getDown..
?
?
?Totodo(888669) 15:55:36
至少.我能證明
?<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
??<constructor-arg>
???<ref bean="rscDataSource" />
??</constructor-arg>
?</bean>
?
?<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
?<bean id="rscTransactionControl" class="org.springframework.orm.hibernate.HibernateTransactionManager">
??<property name="sessionFactory">
???<ref local="rscSessionFactory" />
??</property>
?</bean>
?<bean id="portAssignerDAO" class="bss.resourcemanager.rscass.assport.dao.impl.PortAssignerDAOImpl">
??<property name="sessionFactory">
???<ref bean="rscSessionFactory" />
??</property>
??<property name="jdbcTemplate">
???<ref bean="jdbc" />
??</property>
?</bean>
這個是肯定不在一個事務里的..
?
?Totodo(888669) 15:56:23
portAssignerDAO.updateByJdbc(xxxxxx);
? portAssignerDAO.updateByHb(xxxxxx);
?Totodo(888669) 15:57:30
?從去年上半年開始幾乎沒怎么用HB了....所以關注的不多....
但是HB混用jdbctempate? 記憶深刻啊...
?Totodo(888669) 15:58:32
而且,我們系統在線運行的時候.websphere的日志 一支就是很多報 不在一個事務上,而且綁定不了。 ..
?Totodo(888669) 15:59:36
getDown...在么?
?Totodo(888669) 15:59:38
??? <bean id="baseService" lazy-init="true" abstract="true"
??class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
??<property name="transactionManager" ref="transactionManager" />
??<property name="transactionAttributes">
???<props>
????<prop key="*">PROPAGATION_REQUIRED</prop>
???</props>
??</property>
?</bean>
?
?<bean id="userJdbcDao"
??class="com.gfa4j.demo.jdbc.impl.UserJdbcDaoImpl">
??<property name="dataSource">
???<ref bean="dataSource" />
??</property>
?</bean>
?<bean id="userJdbcService" parent="baseService">
??<property name="target">
???<bean
????class="com.gfa4j.demo.jdbc.impl.UserJdbcServiceImpl">
????<property name="jdbcDao" ref="userJdbcDao" />
???</bean>
??</property>
?</bean>
?? <bean id="userHibernateService" parent="baseService">
??<property name="target">
???<bean
????class="com.gfa4j.demo.service.impl.UserHibernateServiceImpl">
????<property name="userJdbcService" ref="userJdbcService" />
???</bean>
??</property>
?</bean>?
?Totodo(888669) 16:00:05
能否發個 UserJdbcDaoImpl 看一下..
?Totodo(888669) 16:03:20
是否 UserJdbcDaoImpl 直接集成 JdbcDAOSupport?
?Totodo(888669) 16:09:00
Er...
?Totodo(888669) 16:09:44
千古大錯啊......
?Totodo(888669) 16:10:25
我誤導了一波子人......
?Totodo(888669) 16:10:40
非常感謝 getDown 和 水母Spring
netfishx(151431) 16:11:11
?水母
無聲的海浪(4485373) 16:12:28
?
getdown(9486681) 16:16:54
我是直接extends JdbcDAOSupport .?
?Totodo(888669) 16:17:12
對,繼承JdbcDAOSupport
?Totodo(888669) 16:17:18
我明白了.
?Totodo(888669) 16:17:44
可能就是因為 我們的直接
?<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
??<constructor-arg>
???<ref bean="rscDataSource" />
??</constructor-arg>
?</bean>
?Totodo(888669) 16:18:06
我拿你的配置,簡單配了一個,,的確保證在一個事務中.
getdown(9486681) 16:18:15
?
?Totodo(888669) 16:18:50
難道直接 用JdbcTemplate 和 extentds JdbcDAOSupport 有差別..
無聲的海浪(4485373) 16:19:54
沒有差別
從外貌上看需要的參數都是datasource
?Totodo(888669) 16:20:37
我再拿getdown 那種方式換成 我原來的試一下,結果一會兒遍知
無聲的海浪(4485373) 16:21:57
那你把JdbcTemplate的參數換成JdbcTemplate
再try一下
?
?Totodo(888669) 16:22:41
?是的..我另外給dao配置了一個jdbcTempalte 屬性 ,set..
水木-Spring(3330309) 16:23:17
這種方式不行?
無聲的海浪(4485373) 16:23:36
和你用datasource一樣嗎?
無聲的海浪(4485373) 16:24:26
如果一樣,你原來的方式也同樣可以
道理是一樣的
水木-Spring(3330309) 16:25:35
剛才我就說了,getdown用的那個extends是一種方式,如果不想繼承的話,可以注入嘛?
水木-Spring(3330309) 16:26:22
這種注入是沒有問題的.
水木-Spring(3330309) 16:26:36
和繼承是一樣可行的.
無聲的海浪(4485373) 16:26:45
對
?Totodo(888669) 16:26:55
這個知道的拉..其實,我一開始的配置,和getDown沒有本質差別...
無聲的海浪(4485373) 16:27:09
剛才我說的就是水母的意思
水木-Spring(3330309) 16:27:25
總之,這兩種方法都是可以的.
水木-Spring(3330309) 16:27:46
有的人不喜歡繼承,覺得是強耦合,那么可以選擇注入.
getdown(9486681) 16:27:49
?Totodo? getdown 中間不要加大寫 寫成getDown難看....
?Totodo(888669) 16:27:52
一種已經被證實有問題了..
另外一種還沒有被證實..
?Totodo(888669) 16:28:05
正在證實中..
水木-Spring(3330309) 16:28:31
那種有問題?
無聲的海浪(4485373) 16:28:48
... ...是不是你的寫法有問題呢?
水木-Spring(3330309) 16:28:51
繼承還是注入?
?Totodo(888669) 16:29:11
我的這種方式.. 注入.
??<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
???<constructor-arg>
????<ref bean="rscDataSource" />
???</constructor-arg>
??</bean>
??
?<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
?<bean id="rscTransactionControl" class="org.springframework.orm.hibernate.HibernateTransactionManager">
??<property name="sessionFactory">
???<ref local="rscSessionFactory" />
??</property>
?</bean>
?<bean id="portAssignerDAO" class="bss.resourcemanager.rscass.assport.dao.impl.PortAssignerDAOImpl">
??<property name="sessionFactory">
???<ref bean="rscSessionFactory" />
??</property>
??<property name="jdbcTemplate">
???<ref bean="jdbc" />
??</property>
?</bean>
?Totodo(888669) 16:29:46
portAssignerDAO 是 extends HibernateDAOSupport 的..
?Totodo(888669) 16:30:39
同時使用jdbc 和 saveOrUpdate就有問題呢...
水木-Spring(3330309) 16:31:06
你試試同時注入jdbcTemplate和HiberanteTemplate試試.
?Totodo(888669) 16:31:34
先不玩了..晚上拿demo發給大家一起看一下,如果有興趣的話...
反正現在對hb不感冒是了..
水木-Spring(3330309) 16:31:45
呵呵
?Totodo(888669) 16:31:48
要忙了,,失陪一會兒.
無聲的海浪(4485373) 16:32:07
恩
posted on 2006-08-10 18:03 david.turing 閱讀(4126) 評論(0) 編輯 收藏