ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher DeGuise" <christopher.degu...@be-pragmatic.com>
Subject Re: file paths for config files in n-tier architecture
Date Thu, 15 Jan 2009 01:06:13 GMT
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 <robin@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
>

Mime
View raw message