ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shane Courtrille" <shanecourtri...@gmail.com>
Subject Re: Kind of architecture question
Date Mon, 07 May 2007 22:03:27 GMT
I'm just learning iBatis.Net now but I have used the repository <-> mapper
pattern in the past.  Usually what I have done is have the repository
contain a reference to a cache.  It checks the cache before using the
mapping layer to retrieve the item.  The problem I see is your Order
select="CustomerById".  Without knowing more about iBatis I would suggest
you may need to remove that and instead have your repository fill in the
reference after it gets the Order.  Definitely not a solution I'm in love
with though.

Shane

On 5/7/07, Carlos Peix <peix-listas@praxia.com.ar> wrote:
>
>  Hi all,
>
> I used IBatis.NET with success in various projects now but I am still not
> very happy with my implementations. I'll try to explain my concerns.
>
> My environment is .NET 1.1 but I think .NET 2.0 is the same thing. I
> should say that I try to work guided by the DDD principles, so I access the
> final store through repositories.
>
> I have, for example, an entity Customer (aggregate root or simply a
> persistent identifiable object) and a CustomerRepository with the following
> interface:
>
> Customer CustomerRepository.GetById( object id );
>  IList CustomerRepository.GetAll();
> ...
>
> and I also have a Order and OrderRepository with the following interface
>
> OrderRepository.GetByNumber( int number );
> ...
>
> The problem I face all the time with IBatis is the I get different
> instances if I do:
>
> // implemented with a Mapper.QueryForObject( "CustomerById", id );
> Customer customer1 = CustomerRepository.GetById( object id );
>
>  // implemented with a Mapper.QueryForList( "CustomerAll" );
> Customer customer2 = CustomerRepository.GetAll()[0];
>
>  // implemented with a Mapper.QueryForObject( "OrderByNumber", number );
> // and Customer mapped this way in the OrderResultMap:
> //  <result property="customer" column="CustomerId" select="CustomerById"
> />
> Customer customer3 = OrderRepository.GetByNumber( 100 ).Customer;
>
> But customer1.Id, customer2.Id and customer3.Id are the same.
>
> Ok, this is a situation that need to be controlled, otherwise I could
> modify or check different instances of the same object. I was told
> previously that this is not an IBatis problem and I see why (in fact IBatis
> doesn't know anything about object identity, so it can't control this).
>
> The question is: how are you structuring your code to control that
> situation? there are some "recommended practices"? I started with some ideas
> (one of them include IBatis cache configuration) but I'm not happy with any
> of them.
>
> Sorry about the long post and thanks in advance.
>
> Carlos Peix
>
>
>

Mime
View raw message