I don't like having a copy of providers.config in every project I do.

I've used IBatisNet in several projects using Access, Sql Server 2000,
and Oracle. All of my projects to date have been designed against a
single datasource. I would imagine this is what most people do. Should
I ever choose to port my applications to other databases, IBatisNet
will of course make the task of switching much simpler.

.Net ships with several database providers: OLEDB, Sql Server, Oracle,
ODBC. Could we define those as constant aliases that we can use without
having to have a seperate providers.config file? The current names in
the providers.config file are fine: "OleDb1.1", "sqlServer1.1",
"Odbc1.1", "oracle9.2". Have those 4 providers changed at since the
initial version of IBatisNet? They ship with the Framework and to my
knowledge its not possible to uninstall things like the SqlClient
namespace. If the user wanted to change a default setting, they would
be able to by overwriting the desired properties:

 <provider name="OleDb1.1" useParameterPrefixInSql="true" />

Could we add support for one complete <provider> node inside the
<database> tag of SqlMap.config:

<database>

 <provider 
  assemblyName="System.Data, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" 
  connectionClass="System.Data.OleDb.OleDbConnection" 
  commandClass="System.Data.OleDb.OleDbCommand" 
  parameterClass="System.Data.OleDb.OleDbParameter" 
  parameterDbTypeClass="System.Data.OleDb.OleDbType" 
  parameterDbTypeProperty="OleDbType" 
  dataAdapterClass="System.Data.OleDb.OleDbDataAdapter" 
  commandBuilderClass="System.Data.OleDb.OleDbCommandBuilder" 
  usePositionalParameters = "true"
  useParameterPrefixInSql = "false"
  useParameterPrefixInParameter = "false"
  parameterPrefix = "" />

 <dataSource
  name="abc" 
  connectionString="def"/>

</database>

That would still allow someone to specifiy a provider without being
overwhelmed with the default providers.config file. The provider.config
file is up to 10 providers (which is a good thing!).

It would also be nice if I could populate the <properties> node in
SqlMap.config with global properties instead of having to specify an
external file. If a property file only has one property in it, why not
just put it in SqlMap.config? Having an external properties file is
just another small file I need to worry about.

Do other people get tired of writing the same <selectKey> over and over
in their insert statments? I know I can define a global property and
reference that using the ${selectKey} notation but even that gets
tedious after a while. Another idea may be to include the ability to
set a defaultSelectKey attribute on the <provider> tag. That way when I
switch from Access to MySql I don't have to go searching to see that I
need to change @@IDENTITY To LAST_INSERT_ID().

Here's an example that sums everything up:

<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
 xsi:noNamespaceSchemaLocation="SqlMapConfig.xsd">

<settings>
 <setting useStatementNamespaces="true"/>
 <setting cacheModelsEnabled="false"/>
</settings>
        
<properties>
 <add key="GetDate" value="NOW()" />
</properties>

<database>
 <provider name="OleDb1.1" defaultSelectKey="SELECT @@IDENTITY"/>
 <dataSource name="abc" connectionString="xyz" />
</database>
        
<sqlMaps>
 <sqlMap embedded="Bar.xml, Foo.Data"/>
 <sqlMap embedded="Baz.xml, Foo.Data" />
</sqlMaps>
        
</sqlMapConfig>

Comments, suggestions, cool, not cool?

- Ron

Reply via email to