ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlos Peix" <peix-lis...@praxia.com.ar>
Subject Kind of architecture question
Date Mon, 07 May 2007 21:55:28 GMT
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

View raw message