ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ron Grabowski (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Commented: (IBATISNET-86) Make _mapper in IBatisNet.DataMapper.Mapper protected, not private
Date Wed, 06 Jul 2005 22:05:14 GMT
    [ http://issues.apache.org/jira/browse/IBATISNET-86?page=comments#action_12315184 ] 

Ron Grabowski commented on IBATISNET-86:
----------------------------------------

It would be nice to be able to specify where the sqlMap.config file is located when using
IBatisNet.DataMapper.Mapper.Instance(). One possible place for setting this value is from
a key in <appSettings>.  Having a config variable that points to another config variable
is kind of lame.

The quick start guide:

 http://opensource.atlassian.com/confluence/oss/display/IBATIS/Quick+Start+Guide

recommends using your own static Mapper if you need to load sqlMap.config from somewhere other
than its default location. I think that's acceptable.

If _mapper were protected, it would make writing your own static Mapper class much shorter:

namespace CompanyName.Project.Persistence.DataMapper
{
 public class Mapper : IBatisNet.DataMapper.Mapper
 {
  protected static void InitMapper()
  {
   DomSqlMapBuilder builder = new DomSqlMapBuilder();
   _mapper = builder.Configure("App_Includes\\IBatisNet\\sqlMap.config");
  }
 }
}

but I don't think you could have two classes extend IBatisNet.DataMapper.Mapper pointing to
two different databases. For example:

 SqlMapper oracle = CompanyName.Project.Persistence.OracleDataMapper.Instance();
 SqlMapper sqlServer = CompanyName.Project.Persistance.SqlServerDataMapper.Instance();

The InitMapper method of SqlServerDataMapper would never call its InitMapper becuase the static
_mapper in the base class has already initalized by OracleDataMapper. I haven't tested that
so I could be wrong...

FYI, the quick start guide has this code:

 protected static void Configure (object obj)
 {
  _mapper = (SqlMapper) obj;
 }

while the Mapper.cs in SVN has this:

 protected static void Configure (object obj)
 {
  _mapper = null;
 }

The Configure method is the callback method called when the config file changes. Perhaps a
better name would be ConfigurationChanged or Reset.

The original NPetshop app uses the name Reset:

 http://svn.apache.org/repos/asf/ibatis/trunk/cs/npetshop/NPetshop.Service/ServiceConfig.cs

> Make _mapper in IBatisNet.DataMapper.Mapper protected, not private
> ------------------------------------------------------------------
>
>          Key: IBATISNET-86
>          URL: http://issues.apache.org/jira/browse/IBATISNET-86
>      Project: iBatis for .NET
>         Type: Improvement
>     Versions: DataMapper 1.1, DataMapper 1.2.0, DataMapper 1.2.1
>     Reporter: Chris Weisel
>     Assignee: Gilles Bayon
>     Priority: Trivial

>
> I'm setting up IBatisNet DataMapper to use an embedded sqlmap.config, and so I can't
use the provided Mapper class.  The only difference between what I'm doing and the standard
(and I would guess that this applies to most other users as well) is that I need to change
the InitMapper() method.  
> protected static void InitMapper()
> {
> 	DomSqlMapBuilder builder = new DomSqlMapBuilder();
> 	_mapper = builder.Configure("Resources.sqlmap.config, Project.Name.Persistence);
> }
> This is an example of the change I need to make.  If the _mapper variable were protected,
instead of private, I could simply extend Mapper and override InitMapper and be done with
it.  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message