Issue Details (XML | Word | Printable)

Key: SPR-2895
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Daigo Kobayashi
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Framework

Read iBatis configuration file as InputStream to fix iBatis's encoding issue.

Created: 29/Nov/06 07:23 PM   Updated: 21/Dec/06 10:04 AM   Resolved: 30/Nov/06 06:19 AM
Component/s: SpringDA
Affects Version/s: 2.0 final
Fix Version/s: 2.0.2

Time Tracking:
Not Specified

Environment:
WindowsXP
JDK 1.5.0_09


 Description  « Hide

Current iBatis have severe encoding issue. But this will fix in next release.(I heard iBatis 2.3 will release later this week.)
http://issues.apache.org/jira/browse/IBATIS-349

However to apply this fix, SqlMapClientFactoryBean modification is necessary.
Modification is just trivial.

Current spring 2.0 and 2.0.1 has following code on SqlMapClientFactoryBean
try {
// Build the SqlMapClient.
InputStream is = this.configLocation.getInputStream();
this.sqlMapClient = (this.sqlMapClientProperties != null) ?
SqlMapClientBuilder.buildSqlMapClient(new InputStreamReader(is), this.sqlMapClientProperties) :
SqlMapClientBuilder.buildSqlMapClient(new InputStreamReader(is));

// Tell the SqlMapClient to use the given DataSource, if any.
if (this.dataSource != null) {
TransactionConfig transactionConfig = (TransactionConfig) this.transactionConfigClass.newInstance();
DataSource dataSourceToUse = this.dataSource;
if (this.useTransactionAwareDataSource && !(this.dataSource instanceof TransactionAwareDataSourceProxy)) { dataSourceToUse = new TransactionAwareDataSourceProxy(this.dataSource); }
transactionConfig.setDataSource(dataSourceToUse);
transactionConfig.initialize(this.transactionConfigProperties);
applyTransactionConfig(this.sqlMapClient, transactionConfig);
}
}

Following two line need to modify.
SqlMapClientBuilder.buildSqlMapClient(new InputStreamReader(is), this.sqlMapClientProperties) :
SqlMapClientBuilder.buildSqlMapClient(new InputStreamReader(is));

Modification is just trivial. I think just remove new InputStreamReader(is) is enough.
SqlMapClientBuilder.buildSqlMapClient(is, this.sqlMapClientProperties) :
SqlMapClientBuilder.buildSqlMapClient(is);

This worked fine on my environment. Of cause iBatis library update is necessary. (Currently we can't download iBatis 2.3, so I checked out latest source and build myself.)



Juergen Hoeller added a comment - 30/Nov/06 06:19 AM

Thanks for pointing this out! I've added a corresponding reflection check, which uses the InputStream-based API if available, else falls back to the traditional Reader-based API. This allows us to leverage this new iBATIS 2.3 feature while remaining compatible with iBATIS 2.1/2.2.

This should already be available in the next nightly 2.0.2 snapshot (http://www.springframework.org/snapshots). Feel free to give it an early try...

Juergen


Daigo Kobayashi added a comment - 03/Dec/06 09:54 PM

Thank you for fixing this problem. I tried latest nightly build and worked fine.

If possible, please update dependency libraries, iBatis 2.2.0 to 2.3.0. iBatis 2.3 was released on December 1, 2006.


Juergen Hoeller added a comment - 21/Dec/06 10:04 AM

I have upgraded the iBATIS version that we ship (and compile against) to 2.3.0. This also allows to have a more efficient reflection implementation in SqlMapClientFactoryBean, which will be available in the next nightly snapshot (feel free to give this another try)...

Juergen