You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Robin Silver <ro...@sharedevent.com> on 2009/01/14 17:06:38 UTC

file paths for config files in n-tier architecture

Hey all,

I have 4 facets to my application, Web, Test, Services, Data.

Web - the website
Test - the token test project... ;)
Services - interface between web and underlying persistence layer (and additional services)
Data - my data model, POCO's etc.

Assume the scenario where there is a "List All Customer's" button on my page.

Admin User clicks it and web calls CustomerService.ListAllCustomers().  This in turn calls the iBatis structure sort of like...

ArrayList al = (ArrayList)Mapper.Instance().QueryForList("SelectAll", null);

The SqlMap.config and CustomerMapping.xml files are in my Services project.

When I run this, I get the error:

Unable to load file via resource "SqlMap.config" as resource. Cause : Could not find file 'C:\Projects\TestProject\TestProject.Web\SqlMap.config'.

It seems to want to load the config from the calling project (web), not the project in which the actual code resides(services).  When I look at the NPetStore example, the config files are in the web also.

My question is, is there any way to configure it to look for files in the services project instead?  I don't want to have any reference to IBatis in my Web if at all possible.

Thx,
Rob

RE: file paths for config files in n-tier architecture

Posted by Vincent Apesa <va...@hotmail.com>.
Correct me if I'm wrong, isn't the code example from the V1 src and not V3?
 
thanks,
Vince



Date: Wed, 14 Jan 2009 20:06:13 -0500From: christopher.deguise@be-pragmatic.comTo: user-cs@ibatis.apache.orgSubject: Re: file paths for config files in n-tier architectureThe way I handled this was to use the code from Example 4.4 and drive all IBatis request through the custom mapper. In addition I altered the InitMapper method to look something like this:DomSqlMapBuilder builder = new DomSqlMapBuilder();XmlDocument sqlMapConfig = Resources.GetEmbeddedResourceAsXmlDocument("fully.qualified.embedded.resource.SqlMap.config, SomeAssembly");_Mapper = builder.Configure(sqlMapConfig);       Make sure you mark your config files as embedded resources. With my projects I do not ship any raw .xml/.config files, they are all bundled inside a library.Hope that helps.Chirs
On Wed, Jan 14, 2009 at 11:06 AM, Robin Silver <ro...@sharedevent.com> wrote:



Hey all,
 
I have 4 facets to my application, Web, Test, Services, Data.  
 
Web – the website
Test – the token test project… ;)
Services – interface between web and underlying persistence layer (and additional services)
Data – my data model, POCO's etc.
 
Assume the scenario where there is a "List All Customer's" button on my page.  
 
Admin User clicks it and web calls CustomerService.ListAllCustomers().  This in turn calls the iBatis structure sort of like…
 
ArrayList al = (ArrayList)Mapper.Instance().QueryForList("SelectAll", null);
            
The SqlMap.config and CustomerMapping.xml files are in my Services project.  
 
When I run this, I get the error: 
 
Unable to load file via resource "SqlMap.config" as resource. Cause : Could not find file 'C:\Projects\TestProject\TestProject.Web\SqlMap.config'.
 
It seems to want to load the config from the calling project (web), not the project in which the actual code resides(services).  When I look at the NPetStore example, the config files are in the web also. 
 
My question is, is there any way to configure it to look for files in the services project instead?  I don't want to have any reference to IBatis in my Web if at all possible.
 
Thx,
Rob
_________________________________________________________________
Windows Live™: Keep your life in sync. 
http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t1_allup_howitworks_012009

embeded maps in V3

Posted by Vincent Apesa <va...@hotmail.com>.
In case anyone wants to know, I found the solution for loading maps files from a DLL in V3. I looked in the UnitTests. I did not immediately find it since  a lot of the class names have changed. Here is some example code for creating an IDataMapper:


=============================

  string uri = "assembly://MyApp/Config/SqlMap.config";
  IResource resource = ResourceLoaderRegistry.GetResource(uri);

  IConfigurationEngine engine = new DefaultConfigurationEngine();
  engine.RegisterInterpreter(new XmlConfigurationInterpreter(resource));

  IMapperFactory mapperFactory = engine.BuildMapperFactory();
  mapper = ((IDataMapperAccessor)mapperFactory).DataMapper;

=============================

cheers,
Vince


  ----- Original Message ----- 
  From: Christopher DeGuise 
  To: user-cs@ibatis.apache.org 
  Sent: Wednesday, January 14, 2009 8:06 PM
  Subject: Re: file paths for config files in n-tier architecture


  The way I handled this was to use the code from Example 4.4 and drive all IBatis request through the custom mapper. In addition I altered the InitMapper method to look something like this:

  DomSqlMapBuilder builder = new DomSqlMapBuilder();
  XmlDocument sqlMapConfig = Resources.GetEmbeddedResourceAsXmlDocument("fully.qualified.embedded.resource.SqlMap.config, SomeAssembly");
  _Mapper = builder.Configure(sqlMapConfig);       

  Make sure you mark your config files as embedded resources. With my projects I do not ship any raw .xml/.config files, they are all bundled inside a library.

  Hope that helps.
  Chirs



  On Wed, Jan 14, 2009 at 11:06 AM, Robin Silver <ro...@sharedevent.com> wrote:

    Hey all,



    I have 4 facets to my application, Web, Test, Services, Data.  



    Web – the website

    Test – the token test project… ;)

    Services – interface between web and underlying persistence layer (and additional services)

    Data – my data model, POCO's etc.



    Assume the scenario where there is a "List All Customer's" button on my page.  



    Admin User clicks it and web calls CustomerService.ListAllCustomers().  This in turn calls the iBatis structure sort of like…



    ArrayList al = (ArrayList)Mapper.Instance().QueryForList("SelectAll", null);

                

    The SqlMap.config and CustomerMapping.xml files are in my Services project.  



    When I run this, I get the error: 



    Unable to load file via resource "SqlMap.config" as resource. Cause : Could not find file 'C:\Projects\TestProject\TestProject.Web\SqlMap.config'.



    It seems to want to load the config from the calling project (web), not the project in which the actual code resides(services).  When I look at the NPetStore example, the config files are in the web also. 



    My question is, is there any way to configure it to look for files in the services project instead?  I don't want to have any reference to IBatis in my Web if at all possible.



    Thx,

    Rob

Re: file paths for config files in n-tier architecture

Posted by Christopher DeGuise <ch...@be-pragmatic.com>.
The way I handled this was to use the code from Example
4.4<http://ibatis.apache.org/docs/dotnet/datamapper/ch04s04.html>and
drive all IBatis request through the custom mapper. In addition I
altered the InitMapper method to look something like this:

DomSqlMapBuilder builder = new DomSqlMapBuilder();
XmlDocument sqlMapConfig =
Resources.GetEmbeddedResourceAsXmlDocument("fully.qualified.embedded.resource.SqlMap.config,
SomeAssembly");
_Mapper = builder.Configure(sqlMapConfig);

Make sure you mark your config files as embedded resources. With my projects
I do not ship any raw .xml/.config files, they are all bundled inside a
library.

Hope that helps.
Chirs


On Wed, Jan 14, 2009 at 11:06 AM, Robin Silver <ro...@sharedevent.com>wrote:

>  Hey all,
>
>
>
> I have 4 facets to my application, Web, Test, Services, Data.
>
>
>
> Web – the website
>
> Test – the token test project… ;)
>
> Services – interface between web and underlying persistence layer (and
> additional services)
>
> Data – my data model, POCO's etc.
>
>
>
> Assume the scenario where there is a "List All Customer's" button on my
> page.
>
>
>
> Admin User clicks it and web calls CustomerService.ListAllCustomers().
> This in turn calls the iBatis structure sort of like…
>
>
>
> ArrayList al = (ArrayList)Mapper.Instance().QueryForList("SelectAll",
> null);
>
>
>
> The SqlMap.config and CustomerMapping.xml files are in my Services
> project.
>
>
>
> When I run this, I get the error:
>
>
>
> *Unable to load file via resource "SqlMap.config" as resource. Cause :
> Could not find file 'C:\Projects\TestProject\TestProject.Web\SqlMap.config'.
> *
>
>
>
> It seems to want to load the config from the calling project (web), not the
> project in which the actual code resides(services).  When I look at the
> NPetStore example, the config files are in the web also.
>
>
>
> My question is, is there any way to configure it to look for files in the
> services project instead?  I don't want to have any reference to IBatis in
> my Web if at all possible.
>
>
>
> Thx,
>
> Rob
>

Embedded map files in V3

Posted by Vincent Apesa <va...@hotmail.com>.
Hello,
    Does anyone have an example of how to use embedded map files in V3? I'm specifically looking for an example of how to construct the IDataMapper.

thanks,
Vince