Return-Path: Delivered-To: apmail-ibatis-user-cs-archive@www.apache.org Received: (qmail 50369 invoked from network); 19 Jul 2006 19:12:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Jul 2006 19:12:25 -0000 Received: (qmail 34905 invoked by uid 500); 19 Jul 2006 19:12:24 -0000 Delivered-To: apmail-ibatis-user-cs-archive@ibatis.apache.org Received: (qmail 34890 invoked by uid 500); 19 Jul 2006 19:12:24 -0000 Mailing-List: contact user-cs-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-cs@ibatis.apache.org Delivered-To: mailing list user-cs@ibatis.apache.org Received: (qmail 34879 invoked by uid 99); 19 Jul 2006 19:12:24 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jul 2006 12:12:24 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of anantatman@gmail.com designates 64.233.182.189 as permitted sender) Received: from [64.233.182.189] (HELO nf-out-0910.google.com) (64.233.182.189) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jul 2006 12:12:23 -0700 Received: by nf-out-0910.google.com with SMTP id c31so330699nfb for ; Wed, 19 Jul 2006 12:12:01 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:references; b=a8/J84+WvaIbemKUeSJuVUh4s2PCRe+IwGuEOy1DvQuGKN015b463valSrmFuB3YlTe1aSAyswrOMe7AslZdVqnvBsHUAacJrq/UKuaM3QPwJ5s7gEgbRtY4dg13KfoIXYOUknH9NHp9nfQmit328w2GYZJvkhrPbF23IZnHKYw= Received: by 10.82.109.19 with SMTP id h19mr26546buc; Wed, 19 Jul 2006 12:12:01 -0700 (PDT) Received: by 10.82.98.10 with HTTP; Wed, 19 Jul 2006 12:12:01 -0700 (PDT) Message-ID: Date: Wed, 19 Jul 2006 15:12:01 -0400 From: "Rahul Singh ( Anant )" Reply-To: rahul.singh@anant.us To: user-cs@ibatis.apache.org Subject: Re: Creating a DataTable from an IList returned from the data mapper In-Reply-To: <7F0155867097E14CA096A1ABEDB72ACC5F4979@bosnaex01.na.miva.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_11682_33044796.1153336321604" References: <7F0155867097E14CA096A1ABEDB72ACC5F4979@bosnaex01.na.miva.net> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_11682_33044796.1153336321604 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Neat. I like. On 7/19/06, Shawn Hinsey wrote: > > Check this out: > > public DataSet SelectDataSet(string statementName, > object parameters) > { > DataSet ds = new DataSet(); > > IMappedStatement statement = > Mapper.GetMappedStatement(statementName); > > RequestScope scope = > > statement.Statement.Sql.GetRequestScope(parameters, > Mapper.OpenConnection()); > > statement.PreparedCommand.Create > (scope, Mapper.LocalSession, > statement.Statement, parameters); > > > Mapper.LocalSession.CreateDataAdapter(scope.IDbCommand).Fill(ds); > > return ds; > } > > > -----Original Message----- > > From: Ron Grabowski [mailto:rongrabowski@yahoo.com] > > Sent: Tuesday, July 18, 2006 6:30 PM > > To: user-cs@ibatis.apache.org > > Subject: RE: Creating a DataTable from an IList returned from > > the data mapper > > > > Not everything has to be OO. Both the Java and .NET > > implementations of iBATIS support dictionary objects. > > DataTables have an advantage over IDictionary with DataViews: > > > > http://tinyurl.com/2cvqh > > http://msdn.microsoft.com/library/default.asp?url=/library/en- > > us/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.asp > > > > and their ability to be serialized through a web service. > > > > IDictionary/DataTables come in handy in reporting situations > > where you don't want to / can't create objects for dynamic > > reports that need a small amount of additional > > sorting/filtering that IDictionary can't provide. I think > > such a method would also help iBATIS get its foot in the > > door. I would love to re-implement sometimes questionable > > helper classes liks this: > > > > SqlHelper.ExecuteDataTable("SELECT * FROM Users") > > > > with ISqlMapper.QueryForDataTable. > > > > Another step in iBATIS' evolution may be a generalized Query method: > > > > DataTable dataTable = > > (DataTable)sqlMapper.Query(dataTableQuery, "SelectAccountById", 5); > > > > Product[] products = > > (Product[])sqlMapper.Query(productArrayQuery, > > "SelectAccountById", 5); > > > > ISqlMapper could be re-implemented this way: > > > > public IList QueryForList(string statement, object parameter) { > > return (IList)Query(queryForList, statement, parameter); } > > > > public object QueryForObject(string statement, object parameter) { > > return Query(queryForObject, statement, parameter); } > > > > Looking far into the future, maybe ISqlMapper would extend > > IDataMapper to extend the mapping concept to more than just SQL: > > > > MusicInfo[] musicInfos = > > dataMapper.Query(musicInfoQuery, "FindMusic"); > > > > --- Alexandre Grenier wrote: > > > > > Although I understand the situation, I wonder if adding support for > > > datasets would defeat the purpose of ibatis by breaking > > down the model > > > it is promoting. > > > > > > My understanding is that ibatis is a base for building a good > > > "Persistence Ignorance" domain model. > > > > > > In the current case you send in a "query" and retrieve > > "Plain Old CLR > > > Objects", so the input is aware of persistence, but the > > output can be > > > 100% focused on the model. > > > > > > In the case you propose, the output being a datatable maintains the > > > concept of persistence after the fact and is not desirable > > in a model. > > > > > > Maybe that's not your case, but I feel in most cases it may lead to > > > bad design and in the long run injecting Non-PI features will blur > > > ibatis' > > > intention. > > > > > > > > > > > > One way around this would be to enable the user to provide > > a mechanism > > > to process the data and build something else than an IList. > > > > > > > > > > > > Alex > > > -- Rahul Singh CEO, Anant http://www.anant.us Office: 7033723268 Mobile: 7036555652 ------=_Part_11682_33044796.1153336321604 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Neat. I like.

On 7/19/06, Shawn Hinsey <Shawn.Hinsey@miva.com> wrote:
Check this out:

                public DataSet SelectDataSet(string statementName,
object parameters)
                {
                        DataSet ds = new DataSet();

                        IMappedStatement statement =
Mapper.GetMappedStatement(statementName);

                        RequestScope scope =

statement.Statement.Sql.GetRequestScope(parameters,
Mapper.OpenConnection());

                        statement.PreparedCommand.Create
                                (scope, Mapper.LocalSession,
statement.Statement, parameters);


Mapper.LocalSession.CreateDataAdapter(scope.IDbCommand).Fill(ds);

                        return ds;
                }

> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com]
> Sent: Tuesday, July 18, 2006 6:30 PM
> To: user-cs@ibatis.apache.org
> Subject: RE: Creating a DataTable from an IList returned from
> the data mapper
>
> Not everything has to be OO. Both the Java and .NET
> implementations of iBATIS support dictionary objects.
> DataTables have an advantage over IDictionary with DataViews:
>
> http://tinyurl.com/2cvqh
> http://msdn.microsoft.com/library/default.asp?url=/library/en-
> us/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.asp
>
> and their ability to be serialized through a web service.
>
> IDictionary/DataTables come in handy in reporting situations
> where you don't want to / can't create objects for dynamic
> reports that need a small amount of additional
> sorting/filtering that IDictionary can't provide. I think
> such a method would also help iBATIS get its foot in the
> door. I would love to re-implement sometimes questionable
> helper classes liks this:
>
>  SqlHelper.ExecuteDataTable("SELECT * FROM Users")
>
> with ISqlMapper.QueryForDataTable.
>
> Another step in iBATIS' evolution may be a generalized Query method:
>
>  DataTable dataTable =
>   (DataTable)sqlMapper.Query(dataTableQuery, "SelectAccountById", 5);
>
>  Product[] products =
>   (Product[])sqlMapper.Query(productArrayQuery,
> "SelectAccountById", 5);
>
> ISqlMapper could be re-implemented this way:
>
>  public IList QueryForList(string statement, object parameter)  {
>   return (IList)Query(queryForList, statement, parameter);  }
>
>  public object QueryForObject(string statement, object parameter)  {
>   return Query(queryForObject, statement, parameter);  }
>
> Looking far into the future, maybe ISqlMapper would extend
> IDataMapper to extend the mapping concept to more than just SQL:
>
>  MusicInfo[] musicInfos =
>   dataMapper.Query(musicInfoQuery, "FindMusic");
>
> --- Alexandre Grenier <Alexandre.Grenier@markettools.com> wrote:
>
> > Although I understand the situation, I wonder if adding support for
> > datasets would defeat the purpose of ibatis by breaking
> down the model
> > it is promoting.
> >
> > My understanding is that ibatis is a base for building a good
> > "Persistence Ignorance" domain model.
> >
> > In the current case you send in a "query" and retrieve
> "Plain Old CLR
> > Objects", so the input is aware of persistence, but the
> output can be
> > 100% focused on the model.
> >
> > In the case you propose, the output being a datatable maintains the
> > concept of persistence after the fact and is not desirable
> in a model.
> >
> > Maybe that's not your case, but I feel in most cases it may lead to
> > bad design and in the long run injecting Non-PI features will blur
> > ibatis'
> > intention.
> >
> >
> >
> > One way around this would be to enable the user to provide
> a mechanism
> > to process the data and build something else than an IList.
> >
> >
> >
> > Alex
>



--
Rahul Singh
CEO, Anant
http://www.anant.us

Office: 7033723268
Mobile: 7036555652 ------=_Part_11682_33044796.1153336321604--