|
From: <jue...@we...> - 2004-05-29 17:54:08
|
Hi again, Brandon, =20 While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does = not necessarily affect the iBATIS support classes that we provide: Those = classes are specifically meant to integrate SQL Maps into Spring's = resource and transaction management, potentially sharing transactions = with other data access strategies within Spring (for example, plain JDBC = or Hibernate). =20 As far as I understand, the SqlMapClient API already allows for simple = one-line operations when using its own resource and transaction = management. So effectively, you don't need to use Spring's = SqlMapClientTemplate in that scenario: Simply use the SqlMapClient = instance directly. Of course, you can still use Spring's = SqlMapClientFactoryBean to set up your SqlMapClient in the application = context, passing it to your DAOs via bean references. =20 A disadvantage that I see with direct SqlMapClient usage is that you = have to deal with checked SQLExceptions that your DAOs throw. However, = that's also the case with your iBATIS transaction demarcation code, so = that will be consistent throughout the application. The alternative is = to use Spring's resource and transaction management: throwing unchecked = DataAccessExceptions from DAOs (like SqlMapClientTemplate does), and = unchecked TransactionExceptions from transaction demarcation code (like = Spring's PlatformTransactionManager interface and declarative = demarcation facilities do). =20 So in the end, there are two choices for using Spring in combination = with iBATIS SQL Maps: either Spring resource and transaction management = (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and = transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use = SqlMapClient directly in your scenario; you can still leverage all of = Spring's IoC facilities. =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections = needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the = SqlMapDaos. This is not good. What happens when someone wants to allow = iBatis to manage transactions on it's own? I think that the datasource = requirement needs to be removed. Setting the datasource via spring = should be optional not required. =20 Brandon Goodin http://www.ibatis.com =20 ________________________________ From: spr...@li... = [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections = needed =20 Greetings, =20 My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring = product and began to explore the code base. I specifically have examined = the iBatis integration and noticed a problem in how the datasource is = being set. =20 In the SqlMapClientTemplate the execute method is using = session.setUserConnection(con);. Setting the connection using = setUserConnection on the SqlMapSession will not take full advantage of = ibatis functionality (i.e. lazy loading will not work). =20 The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The = TransactionManager needs to be set via the SqlMapExecutorDelegate of the = SqlMapClient. The TransactionManager contains the TransactionConfig = which contains the datasource and various other pertinent config info = for transactions. =20 Following is a chunk from the XmlSqlMapClientBuilder that demonstrates = how the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) = Resources.instantiate(type); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= ctions()); errorCtx.setMoreInfo("Check the transactio nmanager properties or = configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could = not instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- =20 From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using = spring transaction management if they so choose). So, the only thing = that is left is for Spring to use the proper implementation of the = TransactionConfig = (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig)= for the configuration of the datasource. The ExternalTransactionConfig = will allow for Spring to manage the commit and rollback functionality = without losing valuable functionality in iBatis (lazy loading). =20 I'd be happy to work on the Spring code base if you would like or = provide you with more insight if you need. Let me know. =20 Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/>=20 =20 |
|
From: <jue...@we...> - 2004-05-29 19:25:33
|
The problem is that we'd pass the DataSource to the iBATIS = TransactionManager here, but not Spring-managed transactional = Connections. SQL Maps would fetch its own Connections from the given = DataSource, failing to participate in Spring-managed transactions (other = than JTA). =20 I'm aware that lazy loading won't work with Spring's current iBATIS = integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? =20 I wouldn't mind letting SQL Maps create its own Connections from the = DataSource for lazy loading, if told to do so. But we'd need to figure = out a way to pass a transactional Connection in for the actual operation = (like we do currently) and still allow for lazy loading via a given = DataSource. =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections = needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL = TransactionConfig to use in the TransactionManager. Please review my previous code. It = shows exactly how that is set. If you feel that iBatis may need to provide = better integrtion points for Spring to take advantage of... feel free to = provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those = classes are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction = management. So effectively, you don't need to use Spring's SqlMapClientTemplate in = that scenario: Simply use the SqlMapClient instance directly. Of course, you = can still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient = in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you = have to deal with checked SQLExceptions that your DAOs throw. However, that's = also the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use = Spring's resource and transaction management: throwing unchecked = DataAccessExceptions from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation = facilities do). So in the end, there are two choices for using Spring in combination = with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the = SqlMapDaos. This is not good. What happens when someone wants to allow iBatis to = manage transactions on it's own? I think that the datasource requirement needs = to be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections = needed Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring = product and began to explore the code base. I specifically have examined the = iBatis integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig = which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates = how the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) = Resources.instantiate(type); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could = not instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is = left is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig)= for the configuration of the datasource. The ExternalTransactionConfig = will allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or = provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Brandon G. <ma...@ph...> - 2004-05-29 19:48:29
|
Thanks for the clarification of Spring's mode of operation. I need to loo= k at the iBatis code and see how we can accomodate. Thanks Brandon Goodin -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 1:25 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed The problem is that we'd pass the DataSource to the iBATIS TransactionManager here, but not Spring-managed transactional Connections. SQL Maps would fetch its own Connections from the given DataSource, faili= ng to participate in Spring-managed transactions (other than JTA). I'm aware that lazy loading won't work with Spring's current iBATIS integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? I wouldn't mind letting SQL Maps create its own Connections from the DataSource for lazy loading, if told to do so. But we'd need to figure ou= t a way to pass a transactional Connection in for the actual operation (like = we do currently) and still allow for lazy loading via a given DataSource. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL TransactionConf= ig to use in the TransactionManager. Please review my previous code. It show= s exactly how that is set. If you feel that iBatis may need to provide bett= er integrtion points for Spring to take advantage of... feel free to provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those clas= ses are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction managemen= t. So effectively, you don't need to use Spring's SqlMapClientTemplate in th= at scenario: Simply use the SqlMapClient instance directly. Of course, you c= an still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you have= to deal with checked SQLExceptions that your DAOs throw. However, that's als= o the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use Spring's resource and transaction management: throwing unchecked DataAccessExcepti= ons from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation faciliti= es do). So in the end, there are two choices for using Spring in combination with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the SqlMapDao= s. This is not good. What happens when someone wants to allow iBatis to mana= ge transactions on it's own? I think that the datasource requirement needs t= o be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections neede= d Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring prod= uct and began to explore the code base. I specifically have examined the iBat= is integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates ho= w the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) Resources.instantiate(ty= pe); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could n= ot instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is lef= t is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig) for the configuration of the datasource. The ExternalTransactionConfig wi= ll allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: <jue...@we...> - 2004-05-29 19:49:36
|
What about initializing the iBATIS TransactionManager in the way that = you suggested, and *still* pass in transactional Connections via = setUserConnection? That could give the best of both worlds: = participating in all kinds of Spring-managed transactions, and allowing = for lazy loading. It would also avoid the need to pass the DataSource to = each and every SQL-Maps-based DAO; a single passing of the DataSource to = the SqlMapClientFactoryBean would then be sufficient. =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:24 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections = needed The problem is that we'd pass the DataSource to the iBATIS = TransactionManager here, but not Spring-managed transactional = Connections. SQL Maps would fetch its own Connections from the given = DataSource, failing to participate in Spring-managed transactions (other = than JTA). I'm aware that lazy loading won't work with Spring's current iBATIS = integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? I wouldn't mind letting SQL Maps create its own Connections from the = DataSource for lazy loading, if told to do so. But we'd need to figure = out a way to pass a transactional Connection in for the actual operation = (like we do currently) and still allow for lazy loading via a given = DataSource. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections = needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL = TransactionConfig to use in the TransactionManager. Please review my previous code. It = shows exactly how that is set. If you feel that iBatis may need to provide = better integrtion points for Spring to take advantage of... feel free to = provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those = classes are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction = management. So effectively, you don't need to use Spring's SqlMapClientTemplate in = that scenario: Simply use the SqlMapClient instance directly. Of course, you = can still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient = in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you = have to deal with checked SQLExceptions that your DAOs throw. However, that's = also the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use = Spring's resource and transaction management: throwing unchecked = DataAccessExceptions from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation = facilities do). So in the end, there are two choices for using Spring in combination = with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the = SqlMapDaos. This is not good. What happens when someone wants to allow iBatis to = manage transactions on it's own? I think that the datasource requirement needs = to be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections = needed Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring = product and began to explore the code base. I specifically have examined the = iBatis integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig = which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates = how the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) = Resources.instantiate(type); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could = not instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is = left is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig)= for the configuration of the datasource. The ExternalTransactionConfig = will allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or = provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: <jue...@we...> - 2004-05-29 20:09:36
|
Actually, this seems to work great: Specify the DataSource once on = SqlMapClientFactoryBean rather than on each DAO, and still set the = UserConnection in SqlMapClientTemplate. The latter simply fetches the = DataSource from the SqlMapClient in this case. As far as I understand = that, this should allow for proper lazy loading... =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:46 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections = needed What about initializing the iBATIS TransactionManager in the way that = you suggested, and *still* pass in transactional Connections via = setUserConnection? That could give the best of both worlds: = participating in all kinds of Spring-managed transactions, and allowing = for lazy loading. It would also avoid the need to pass the DataSource to = each and every SQL-Maps-based DAO; a single passing of the DataSource to = the SqlMapClientFactoryBean would then be sufficient. Juergen ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:24 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections = needed The problem is that we'd pass the DataSource to the iBATIS = TransactionManager here, but not Spring-managed transactional = Connections. SQL Maps would fetch its own Connections from the given = DataSource, failing to participate in Spring-managed transactions (other = than JTA). I'm aware that lazy loading won't work with Spring's current iBATIS = integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? I wouldn't mind letting SQL Maps create its own Connections from the = DataSource for lazy loading, if told to do so. But we'd need to figure = out a way to pass a transactional Connection in for the actual operation = (like we do currently) and still allow for lazy loading via a given = DataSource. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections = needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL = TransactionConfig to use in the TransactionManager. Please review my previous code. It = shows exactly how that is set. If you feel that iBatis may need to provide = better integrtion points for Spring to take advantage of... feel free to = provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those = classes are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction = management. So effectively, you don't need to use Spring's SqlMapClientTemplate in = that scenario: Simply use the SqlMapClient instance directly. Of course, you = can still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient = in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you = have to deal with checked SQLExceptions that your DAOs throw. However, that's = also the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use = Spring's resource and transaction management: throwing unchecked = DataAccessExceptions from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation = facilities do). So in the end, there are two choices for using Spring in combination = with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the = SqlMapDaos. This is not good. What happens when someone wants to allow iBatis to = manage transactions on it's own? I think that the datasource requirement needs = to be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections = needed Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring = product and began to explore the code base. I specifically have examined the = iBatis integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig = which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates = how the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) = Resources.instantiate(type); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could = not instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is = left is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig)= for the configuration of the datasource. The ExternalTransactionConfig = will allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or = provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Brandon G. <ma...@ph...> - 2004-05-29 20:23:03
|
excellent, i'll give it a try. -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 2:07 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Actually, this seems to work great: Specify the DataSource once on SqlMapClientFactoryBean rather than on each DAO, and still set the UserConnection in SqlMapClientTemplate. The latter simply fetches the DataSource from the SqlMapClient in this case. As far as I understand tha= t, this should allow for proper lazy loading... Juergen ________________________________ Von: spr...@li... im Auftrag von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:46 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed What about initializing the iBATIS TransactionManager in the way that you suggested, and *still* pass in transactional Connections via setUserConnection? That could give the best of both worlds: participating= in all kinds of Spring-managed transactions, and allowing for lazy loading. = It would also avoid the need to pass the DataSource to each and every SQL-Maps-based DAO; a single passing of the DataSource to the SqlMapClientFactoryBean would then be sufficient. Juergen ________________________________ Von: spr...@li... im Auftrag von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:24 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed The problem is that we'd pass the DataSource to the iBATIS TransactionManager here, but not Spring-managed transactional Connections. SQL Maps would fetch its own Connections from the given DataSource, faili= ng to participate in Spring-managed transactions (other than JTA). I'm aware that lazy loading won't work with Spring's current iBATIS integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? I wouldn't mind letting SQL Maps create its own Connections from the DataSource for lazy loading, if told to do so. But we'd need to figure ou= t a way to pass a transactional Connection in for the actual operation (like = we do currently) and still allow for lazy loading via a given DataSource. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL TransactionConf= ig to use in the TransactionManager. Please review my previous code. It show= s exactly how that is set. If you feel that iBatis may need to provide bett= er integrtion points for Spring to take advantage of... feel free to provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those clas= ses are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction managemen= t. So effectively, you don't need to use Spring's SqlMapClientTemplate in th= at scenario: Simply use the SqlMapClient instance directly. Of course, you c= an still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you have= to deal with checked SQLExceptions that your DAOs throw. However, that's als= o the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use Spring's resource and transaction management: throwing unchecked DataAccessExcepti= ons from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation faciliti= es do). So in the end, there are two choices for using Spring in combination with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the SqlMapDao= s. This is not good. What happens when someone wants to allow iBatis to mana= ge transactions on it's own? I think that the datasource requirement needs t= o be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections neede= d Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring prod= uct and began to explore the code base. I specifically have examined the iBat= is integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates ho= w the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) Resources.instantiate(ty= pe); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could n= ot instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is lef= t is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig) for the configuration of the datasource. The ExternalTransactionConfig wi= ll allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: <jue...@we...> - 2004-05-29 20:41:32
|
I've just tried with a lazy-loading PaginatedList - works like a charm! = And it still works nicely with the old usage pattern too. =20 Gonna commit it within the next 30 minutes... might take about 2 or 3 = hours to be available from public CVS, though. =20 Brandon, thanks for that really valuable hint :-) Just in time for = 1.0.2, to be released tomorrow. =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 22:25 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections = needed excellent, i'll give it a try. -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 2:07 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Actually, this seems to work great: Specify the DataSource once on SqlMapClientFactoryBean rather than on each DAO, and still set the UserConnection in SqlMapClientTemplate. The latter simply fetches the DataSource from the SqlMapClient in this case. As far as I understand = that, this should allow for proper lazy loading... Juergen ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:46 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed What about initializing the iBATIS TransactionManager in the way that = you suggested, and *still* pass in transactional Connections via setUserConnection? That could give the best of both worlds: = participating in all kinds of Spring-managed transactions, and allowing for lazy loading. = It would also avoid the need to pass the DataSource to each and every SQL-Maps-based DAO; a single passing of the DataSource to the SqlMapClientFactoryBean would then be sufficient. Juergen ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:24 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed The problem is that we'd pass the DataSource to the iBATIS TransactionManager here, but not Spring-managed transactional = Connections. SQL Maps would fetch its own Connections from the given DataSource, = failing to participate in Spring-managed transactions (other than JTA). I'm aware that lazy loading won't work with Spring's current iBATIS integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? I wouldn't mind letting SQL Maps create its own Connections from the DataSource for lazy loading, if told to do so. But we'd need to figure = out a way to pass a transactional Connection in for the actual operation (like = we do currently) and still allow for lazy loading via a given DataSource. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL = TransactionConfig to use in the TransactionManager. Please review my previous code. It = shows exactly how that is set. If you feel that iBatis may need to provide = better integrtion points for Spring to take advantage of... feel free to = provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those = classes are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction = management. So effectively, you don't need to use Spring's SqlMapClientTemplate in = that scenario: Simply use the SqlMapClient instance directly. Of course, you = can still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient = in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you = have to deal with checked SQLExceptions that your DAOs throw. However, that's = also the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use = Spring's resource and transaction management: throwing unchecked = DataAccessExceptions from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation = facilities do). So in the end, there are two choices for using Spring in combination = with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the = SqlMapDaos. This is not good. What happens when someone wants to allow iBatis to = manage transactions on it's own? I think that the datasource requirement needs = to be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections = needed Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring = product and began to explore the code base. I specifically have examined the = iBatis integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig = which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates = how the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) = Resources.instantiate(type); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could = not instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is = left is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig)= for the configuration of the datasource. The ExternalTransactionConfig = will allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or = provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Brandon G. <ma...@ph...> - 2004-05-29 20:57:26
|
excellent, thanks a ton j=FCrgen. Brandon -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 2:39 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed I've just tried with a lazy-loading PaginatedList - works like a charm! A= nd it still works nicely with the old usage pattern too. Gonna commit it within the next 30 minutes... might take about 2 or 3 hou= rs to be available from public CVS, though. Brandon, thanks for that really valuable hint :-) Just in time for 1.0.2,= to be released tomorrow. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 22:25 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed excellent, i'll give it a try. -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 2:07 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Actually, this seems to work great: Specify the DataSource once on SqlMapClientFactoryBean rather than on each DAO, and still set the UserConnection in SqlMapClientTemplate. The latter simply fetches the DataSource from the SqlMapClient in this case. As far as I understand tha= t, this should allow for proper lazy loading... Juergen ________________________________ Von: spr...@li... im Auftrag von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:46 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed What about initializing the iBATIS TransactionManager in the way that you suggested, and *still* pass in transactional Connections via setUserConnection? That could give the best of both worlds: participating= in all kinds of Spring-managed transactions, and allowing for lazy loading. = It would also avoid the need to pass the DataSource to each and every SQL-Maps-based DAO; a single passing of the DataSource to the SqlMapClientFactoryBean would then be sufficient. Juergen ________________________________ Von: spr...@li... im Auftrag von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:24 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed The problem is that we'd pass the DataSource to the iBATIS TransactionManager here, but not Spring-managed transactional Connections. SQL Maps would fetch its own Connections from the given DataSource, faili= ng to participate in Spring-managed transactions (other than JTA). I'm aware that lazy loading won't work with Spring's current iBATIS integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? I wouldn't mind letting SQL Maps create its own Connections from the DataSource for lazy loading, if told to do so. But we'd need to figure ou= t a way to pass a transactional Connection in for the actual operation (like = we do currently) and still allow for lazy loading via a given DataSource. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL TransactionConf= ig to use in the TransactionManager. Please review my previous code. It show= s exactly how that is set. If you feel that iBatis may need to provide bett= er integrtion points for Spring to take advantage of... feel free to provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those clas= ses are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction managemen= t. So effectively, you don't need to use Spring's SqlMapClientTemplate in th= at scenario: Simply use the SqlMapClient instance directly. Of course, you c= an still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you have= to deal with checked SQLExceptions that your DAOs throw. However, that's als= o the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use Spring's resource and transaction management: throwing unchecked DataAccessExcepti= ons from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation faciliti= es do). So in the end, there are two choices for using Spring in combination with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the SqlMapDao= s. This is not good. What happens when someone wants to allow iBatis to mana= ge transactions on it's own? I think that the datasource requirement needs t= o be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections neede= d Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring prod= uct and began to explore the code base. I specifically have examined the iBat= is integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates ho= w the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) Resources.instantiate(ty= pe); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could n= ot instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is lef= t is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig) for the configuration of the datasource. The ExternalTransactionConfig wi= ll allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Fernando M. <fm...@ar...> - 2004-05-29 21:07:18
|
On Saturday 29 May 2004 22:38, j=FCrgen h=F6ller [werk3AT] wrote: > ... Just in time for 1.0.2, to be released tomorrow. http://imdb.com/title/tt0107048/ ;-) |
|
From: <jue...@we...> - 2004-05-29 21:31:39
|
Just committed. As I said, might take a while before it's available from = public CVS. =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 22:59 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections = needed excellent, thanks a ton j=FCrgen. Brandon -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 2:39 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed I've just tried with a lazy-loading PaginatedList - works like a charm! = And it still works nicely with the old usage pattern too. Gonna commit it within the next 30 minutes... might take about 2 or 3 = hours to be available from public CVS, though. Brandon, thanks for that really valuable hint :-) Just in time for = 1.0.2, to be released tomorrow. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 22:25 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed excellent, i'll give it a try. -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 2:07 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Actually, this seems to work great: Specify the DataSource once on SqlMapClientFactoryBean rather than on each DAO, and still set the UserConnection in SqlMapClientTemplate. The latter simply fetches the DataSource from the SqlMapClient in this case. As far as I understand = that, this should allow for proper lazy loading... Juergen ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:46 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed What about initializing the iBATIS TransactionManager in the way that = you suggested, and *still* pass in transactional Connections via setUserConnection? That could give the best of both worlds: = participating in all kinds of Spring-managed transactions, and allowing for lazy loading. = It would also avoid the need to pass the DataSource to each and every SQL-Maps-based DAO; a single passing of the DataSource to the SqlMapClientFactoryBean would then be sufficient. Juergen ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:24 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed The problem is that we'd pass the DataSource to the iBATIS TransactionManager here, but not Spring-managed transactional = Connections. SQL Maps would fetch its own Connections from the given DataSource, = failing to participate in Spring-managed transactions (other than JTA). I'm aware that lazy loading won't work with Spring's current iBATIS integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? I wouldn't mind letting SQL Maps create its own Connections from the DataSource for lazy loading, if told to do so. But we'd need to figure = out a way to pass a transactional Connection in for the actual operation (like = we do currently) and still allow for lazy loading via a given DataSource. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL = TransactionConfig to use in the TransactionManager. Please review my previous code. It = shows exactly how that is set. If you feel that iBatis may need to provide = better integrtion points for Spring to take advantage of... feel free to = provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those = classes are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction = management. So effectively, you don't need to use Spring's SqlMapClientTemplate in = that scenario: Simply use the SqlMapClient instance directly. Of course, you = can still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient = in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you = have to deal with checked SQLExceptions that your DAOs throw. However, that's = also the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use = Spring's resource and transaction management: throwing unchecked = DataAccessExceptions from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation = facilities do). So in the end, there are two choices for using Spring in combination = with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the = SqlMapDaos. This is not good. What happens when someone wants to allow iBatis to = manage transactions on it's own? I think that the datasource requirement needs = to be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections = needed Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring = product and began to explore the code base. I specifically have examined the = iBatis integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig = which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates = how the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) = Resources.instantiate(type); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could = not instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is = left is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig)= for the configuration of the datasource. The ExternalTransactionConfig = will allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or = provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: <jue...@we...> - 2004-05-29 21:36:23
|
:-)) =20 The difference is: This time it's gonna happen. I know, I already said = that earlier too ;-) Argh, release management, argh, time planning... = and the ability to say "rien ne va plus" for a specific release. =20 Some of the stuff that I've still considered for 1.0.2, like Keith's = BatchSqlUpdate class or opening up the ApplicationEventMulticaster, is = now *not* gonna happen for 1.0.2. But today's iBATIS SQL Maps = refinements will be included! =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von Fernando Martins Gesendet: Sa 29.05.2004 23:11 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections = needed On Saturday 29 May 2004 22:38, j=FCrgen h=F6ller [werk3AT] wrote: > ... Just in time for 1.0.2, to be released tomorrow. http://imdb.com/title/tt0107048/ ;-) ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Brandon G. <ma...@ph...> - 2004-05-29 22:37:06
|
Juergen, Did you get the changes for the executeWithRowHandler changes committed? Those are important. Because once the final release of ibatis is out the current integration with Spring will break. I wasn't sure if you got the email because I received an email from the list that said my posting was = too large and it was awaiting approval by the moderator. Brandon > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...] On = Behalf > Of j=FCrgen h=F6ller [werk3AT] > Sent: Saturday, May 29, 2004 2:31 PM > To: spr...@li... > Subject: Re: [Springframework-developer] Ibatis integration = corrections > needed >=20 > :-)) >=20 > The difference is: This time it's gonna happen. I know, I already said > that earlier too ;-) Argh, release management, argh, time planning... = and > the ability to say "rien ne va plus" for a specific release. >=20 > Some of the stuff that I've still considered for 1.0.2, like Keith's > BatchSqlUpdate class or opening up the ApplicationEventMulticaster, is = now > *not* gonna happen for 1.0.2. But today's iBATIS SQL Maps refinements = will > be included! >=20 > Juergen >=20 >=20 > ________________________________ >=20 > Von: spr...@li... im Auftrag = von > Fernando Martins > Gesendet: Sa 29.05.2004 23:11 > An: spr...@li... > Betreff: Re: [Springframework-developer] Ibatis integration = corrections > needed >=20 >=20 >=20 >=20 > On Saturday 29 May 2004 22:38, j=FCrgen h=F6ller [werk3AT] wrote: > > ... Just in time for 1.0.2, to be released tomorrow. >=20 > http://imdb.com/title/tt0107048/ >=20 > ;-) >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle = 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle = 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: <jue...@we...> - 2004-05-29 23:03:18
|
I've actually added the "queryWithRowHandler" method in the course of my =
changes today, and deprecated the "queryForList(..., RowHandler)" =
version. I've noticed the deprecation already at the time of SQL Maps =
2.0 RC4, but somehow forgot to adapt Spring's support classes =
immediately (although I promised to do it on the iBATIS forums).
=20
So if you fetch the DataSource/TransactionManager changes, you should =
get the "queryWithRowHandler" version too. Once we ship SQL Maps 2.0 =
final (probably in Spring 1.0.3?), I'll probably remove the =
"queryForList(..., RowHandler)" method entirely.
=20
Regarding SqlMapClientCallback: That's mainly used for implementing =
SqlMapClientTemplate's one-line operations. It's also available for =
applications, but the only scenario where I actually recommend this is =
statement batching: executor.startBatch, various operations, =
executor.executeBatch(). Such a batch needs to be executed on one single =
SqlMapExecutor, which SqlMapClientCallback provides.
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Brandon Goodin
Gesendet: So 30.05.2004 01:53
An: spr...@li...
Betreff: RE: [Springframework-developer] Ibatis integration corrections =
needed
Sorry if this was received 2 or 3 times. I received a message email back =
2
times that said the last one I sent was too large. So, I felt it =
important
to post again.
Followin are some issues that need to be resolved...
Line 54 of SqlMapClientOperations:
List queryForList(String statementName, Object parameterObject, =
RowHandler
rowHandler)
throws DataAccessException;
=20
should be..
void queryWithRowhandler(String statementName, Object parameterObject,
RowHandler rowHandler)
throws DataAccessException;
=20
Line 185-192 of SqlMapClientTemplate needs to be changed in a similar
manner:
public List queryForList(final String statementName, final Object
parameterObject,
final RowHandler rowHandler) throws DataAccessException {
return executeWithListResult(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws
SQLException {
return executor.queryForList(statementName, parameterObject,
rowHandler);
}
});
}
Should be:
I am assuming you do not want to implement another method on your
SqlMapClientCallback just to accommodate the queryWithRowHandler. So, I
simply pass back a null from the doInSqlMapClient of the
SqlMapClientCallback implementation and ignore it.
public void queryWithRowHandler(final String statementName, final Object
parameterObject,
final RowHandler rowHandler) throws DataAccessException {
executeWithRowHandler(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws
SQLException {
executor.queryWithRowHandler(statementName, parameterObject,
rowHandler);
return null;
}
});
}
Also, the following should be added to the SqlMapClientTemplate
/**
* Execute the given data access action on a SqlMapSession
* with a RowHandler.
* @param action callback object that specifies the data access action
* @return the List result
* @throws DataAccessException in case of SQL Maps errors
*/
public void executeWithRowHandler(SqlMapClientCallback action) throws
DataAccessException {
execute(action);
}
Apart from all of this I am rather curious about the purpose the
SqlMapClientCallback? I read the javadoc and am wondering what role it =
plays
in the process of Spring integration with iBatis. Could you provide me =
with
a explanation of it's role?
Thanks,
Brandon Goodin
http://www.ibatis.com
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3D3149&alloc_id=3D8166&op=3Dclick
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: <jue...@we...> - 2004-06-08 19:28:21
|
Brandon, =20 Have you had a chance to review Spring 1.0.2's support for SQL Maps 2.0? = Are you happy with it so far? If there's any further thing we can do, = let's try to nail it down for Spring 1.0.3, scheduled for end of June. =20 Actually, if SQL Maps 2.0 gets final early enough, we could ship it with = Spring 1.0.3 .That would be ideal timing :-) =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 22:59 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections = needed excellent, thanks a ton j=FCrgen. Brandon -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 2:39 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed I've just tried with a lazy-loading PaginatedList - works like a charm! = And it still works nicely with the old usage pattern too. Gonna commit it within the next 30 minutes... might take about 2 or 3 = hours to be available from public CVS, though. Brandon, thanks for that really valuable hint :-) Just in time for = 1.0.2, to be released tomorrow. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 22:25 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed excellent, i'll give it a try. -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 2:07 PM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Actually, this seems to work great: Specify the DataSource once on SqlMapClientFactoryBean rather than on each DAO, and still set the UserConnection in SqlMapClientTemplate. The latter simply fetches the DataSource from the SqlMapClient in this case. As far as I understand = that, this should allow for proper lazy loading... Juergen ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:46 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed What about initializing the iBATIS TransactionManager in the way that = you suggested, and *still* pass in transactional Connections via setUserConnection? That could give the best of both worlds: = participating in all kinds of Spring-managed transactions, and allowing for lazy loading. = It would also avoid the need to pass the DataSource to each and every SQL-Maps-based DAO; a single passing of the DataSource to the SqlMapClientFactoryBean would then be sufficient. Juergen ________________________________ Von: spr...@li... im Auftrag = von j=FCrgen h=F6ller [werk3AT] Gesendet: Sa 29.05.2004 21:24 An: spr...@li... Betreff: Re: [Springframework-developer] Ibatis integration corrections needed The problem is that we'd pass the DataSource to the iBATIS TransactionManager here, but not Spring-managed transactional = Connections. SQL Maps would fetch its own Connections from the given DataSource, = failing to participate in Spring-managed transactions (other than JTA). I'm aware that lazy loading won't work with Spring's current iBATIS integration strategy. However, I'm not aware of any other disadvantages; = can you give details in that respect? I wouldn't mind letting SQL Maps create its own Connections from the DataSource for lazy loading, if told to do so. But we'd need to figure = out a way to pass a transactional Connection in for the actual operation (like = we do currently) and still allow for lazy loading via a given DataSource. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 20:48 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL = TransactionConfig to use in the TransactionManager. Please review my previous code. It = shows exactly how that is set. If you feel that iBatis may need to provide = better integrtion points for Spring to take advantage of... feel free to = provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those = classes are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction = management. So effectively, you don't need to use Spring's SqlMapClientTemplate in = that scenario: Simply use the SqlMapClient instance directly. Of course, you = can still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient = in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you = have to deal with checked SQLExceptions that your DAOs throw. However, that's = also the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use = Spring's resource and transaction management: throwing unchecked = DataAccessExceptions from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation = facilities do). So in the end, there are two choices for using Spring in combination = with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag = von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the = SqlMapDaos. This is not good. What happens when someone wants to allow iBatis to = manage transactions on it's own? I think that the datasource requirement needs = to be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections = needed Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring = product and began to explore the code base. I specifically have examined the = iBatis integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig = which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates = how the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) = Resources.instantiate(type); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could = not instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is = left is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig)= for the configuration of the datasource. The ExternalTransactionConfig = will allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or = provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Brandon G. <br...@za...> - 2004-05-29 18:46:03
|
The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL TransactionConf= ig to use in the TransactionManager. Please review my previous code. It show= s exactly how that is set. If you feel that iBatis may need to provide bett= er integrtion points for Spring to take advantage of... feel free to provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those clas= ses are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction managemen= t. So effectively, you don't need to use Spring's SqlMapClientTemplate in th= at scenario: Simply use the SqlMapClient instance directly. Of course, you c= an still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you have= to deal with checked SQLExceptions that your DAOs throw. However, that's als= o the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use Spring's resource and transaction management: throwing unchecked DataAccessExcepti= ons from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation faciliti= es do). So in the end, there are two choices for using Spring in combination with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the SqlMapDao= s. This is not good. What happens when someone wants to allow iBatis to mana= ge transactions on it's own? I think that the datasource requirement needs t= o be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections neede= d Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring prod= uct and began to explore the code base. I specifically have examined the iBat= is integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates ho= w the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) Resources.instantiate(ty= pe); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could n= ot instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is lef= t is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig) for the configuration of the datasource. The ExternalTransactionConfig wi= ll allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Brandon G. <ma...@ph...> - 2004-05-29 18:48:55
|
The issue here of setting the datasource still remains. If you set the connection via the setUserConnection it doesn't take full advantage of ibatis. However, it is possible to allow for Spring to be the iBatis TransactionManager. You simply need to set up an EXTERNAL TransactionConf= ig to use in the TransactionManager. Please review my previous code. It show= s exactly how that is set. If you feel that iBatis may need to provide bett= er integrtion points for Spring to take advantage of... feel free to provide suggestions. Thanks, Brandon Goodin http://www.ibatis.com -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of j=FCrgen h=F6ller [werk3AT] Sent: Saturday, May 29, 2004 11:53 AM To: spr...@li... Subject: Re: [Springframework-developer] Ibatis integration corrections needed Hi again, Brandon, While I agree that Spring allows iBATIS users to choose between Spring's = own transaction management and iBATIS transaction management, this does not necessarily affect the iBATIS support classes that we provide: Those clas= ses are specifically meant to integrate SQL Maps into Spring's resource and transaction management, potentially sharing transactions with other data access strategies within Spring (for example, plain JDBC or Hibernate). As far as I understand, the SqlMapClient API already allows for simple one-line operations when using its own resource and transaction managemen= t. So effectively, you don't need to use Spring's SqlMapClientTemplate in th= at scenario: Simply use the SqlMapClient instance directly. Of course, you c= an still use Spring's SqlMapClientFactoryBean to set up your SqlMapClient in the application context, passing it to your DAOs via bean references. A disadvantage that I see with direct SqlMapClient usage is that you have= to deal with checked SQLExceptions that your DAOs throw. However, that's als= o the case with your iBATIS transaction demarcation code, so that will be consistent throughout the application. The alternative is to use Spring's resource and transaction management: throwing unchecked DataAccessExcepti= ons from DAOs (like SqlMapClientTemplate does), and unchecked TransactionExceptions from transaction demarcation code (like Spring's PlatformTransactionManager interface and declarative demarcation faciliti= es do). So in the end, there are two choices for using Spring in combination with iBATIS SQL Maps: either Spring resource and transaction management (-> coding your DAOs with SqlMapClientTemplate), or iBATIS resource and transaction management (-> coding your DAOs with SqlMapClient directly). = I don't see a need to rework SqlMapClientTemplate here: Simply use SqlMapClient directly in your scenario; you can still leverage all of Spring's IoC facilities. Juergen ________________________________ Von: spr...@li... im Auftrag von Brandon Goodin Gesendet: Sa 29.05.2004 07:42 An: spr...@li... Betreff: RE: [Springframework-developer] Ibatis integration corrections needed Also, after some exploration I have discovered that Spring requires that = the Datasource be set via the <property name=3D"dataSource"> on the SqlMapDao= s. This is not good. What happens when someone wants to allow iBatis to mana= ge transactions on it's own? I think that the datasource requirement needs t= o be removed. Setting the datasource via spring should be optional not required. Brandon Goodin http://www.ibatis.com ________________________________ From: spr...@li... [mailto:spr...@li...] On Behalf = Of Brandon Goodin Sent: Friday, May 28, 2004 6:57 PM To: spr...@li... Subject: [Springframework-developer] Ibatis integration corrections neede= d Greetings, My name is Brandon Goodin. I am committer on the iBatis project. As I've = had time recently I've become increasingly more familiar with the Spring prod= uct and began to explore the code base. I specifically have examined the iBat= is integration and noticed a problem in how the datasource is being set. In the SqlMapClientTemplate the execute method is using session.setUserConnection(con);. Setting the connection using setUserConnection on the SqlMapSession will not take full advantage of ibatis functionality (i.e. lazy loading will not work). The short explanation is that Spring needs to set the the Datasource via = the TransactionConfig which is stored in the TransactionManager. The TransactionManager needs to be set via the SqlMapExecutorDelegate of the SqlMapClient. The TransactionManager contains the TransactionConfig which contains the datasource and various other pertinent config info for transactions. Following is a chunk from the XmlSqlMapClientBuilder that demonstrates ho= w the datasource should be configured in ibatis: ---- start code --- TransactionManager txManager =3D null; try { errorCtx.setMoreInfo("Check the transaction manager type or class."); TransactionConfig config =3D (TransactionConfig) Resources.instantiate(ty= pe); config.setDataSource(dataSource); config.setMaximumConcurrentTransactions(client.getDelegate().getMaxTransa= cti ons()); errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration."); config.initialize(initProperties); errorCtx.setMoreInfo(null); txManager =3D new TransactionManager(config); } catch (Exception e) { if (e instanceof SqlMapException) { throw (SqlMapException) e; } else { throw new SqlMapException("Error initializing TransactionManager. Could n= ot instantiate TransactionConfig. Cause: " + e, e); } } client.getDelegate().setTxManager(txManager); --- end code --- From what I can tell Spring allows for iBatis users to take advantage of = the iBatis transaction facilities if they choose (i.e. avoid using spring transaction management if they so choose). So, the only thing that is lef= t is for Spring to use the proper implementation of the TransactionConfig (com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig) for the configuration of the datasource. The ExternalTransactionConfig wi= ll allow for Spring to manage the commit and rollback functionality without losing valuable functionality in iBatis (lazy loading). I'd be happy to work on the Spring code base if you would like or provide you with more insight if you need. Let me know. Thanks, Brandon Goodin http://www.ibatis.com <http://www.ibatis.com/> ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |