ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Miika Mäkinen" <mmi...@gmail.com>
Subject Re: Multiple resultsets in data mapper
Date Sat, 26 May 2007 09:14:07 GMT
Hi, thanks des spending thoughts on this... However that kind of
lookup thing doesn't really feel suitable for me.  Let's say we need
to add for example two more collections in to company: contact and
paymentType. And let's say that we have half a million companies in
the db. Somehow the lookup idea just doesn't feel right. I think i'll
look through some other ORMs or just generate code to fill my objects.
Thanks for the help to all though, i've learnt a lot about how orms
work!

On 5/26/07, Nguyen, Tom <Tom.Nguyen@rels.info> wrote:
> If I understand correctly, you are thinking about something similar to
> loading and caching lookup tables.  IbatisNet does not have something that
> is optimized to your requirement.
>
> I think there are two different views on this:
> 1)  I think most people out there display massive data through a view like
> objects.  Joins are natural and are very fast in the database.  Ibatis also
> makes it possible to define dynamic view in xml mapping files.  This is the
> easiest approach.
>
> 2)  Anything that requires optimization will require custom code.  It's not
> too hard with .net 2.0.
>
> One example is:
>
> 1st) Implement some kind of registry where it will lazy load your lookup
> base on the lookup type.
>
> 2nd) Implement a container similar to Nullable type.
>
> Pseudo code:
> ------
> public class LookupRegistry
> {
> 	Register<GenderType>(gendertype ibatisnet statement)
> 	{
> 		// store statement by gender type
> 		// or store dictionary from execute of statement
> 	}
>
> 	Locate<T>(string key)
> 	{
> 		// locate ibatisnet statement for typeof(T)
> 		// execute ibatisnet statement
> 		// or get dictionary from typeof(T)
> 		// get value from dictionary
> 	}
> }
>
> public class LookupContainer<T>
> {
> 	... snip ...
> 	  /// <summary>
>         /// Convert FromString.
>         /// </summary>
>         /// <param name="value"></param>
>         /// <returns></returns>
>         public static implicit operator GenderType(string value)
>         {
>             return LookupRegistry.Locate<GenderType>(value);
>         }
> }
>
> public class GenderType
> {
> 	String TypeCode IN ('M', 'F');
> 	String Description IN ('Male', 'Female');
> }
>
> public class Person
> {
> 	LookupContainer<GenderType> Gender;
> }
>
> // bada bing.. bada booom..
> // usage:
> Person p = new Person();
> p.Gender = 'M';
>
> -----
>
> so one would load Person.Gender value ('M' or 'F') from database and the the
> GenderType class would automatically lookup it's Description ('Male' or
> 'Female').  You can even use IbatisNet Cache configuration to handle caching
> and flush duration during loading of your lookups.
>
> Regards,
>
> Tom Nguyen
> Sr. Developer
> tom.nguyen@rels.info
> Rels Valuation
>
>
> -----Original Message-----
> From: Miika Mäkinen [mailto:mmiika@gmail.com]
> Sent: Friday, May 25, 2007 10:30 AM
> To: user-cs@ibatis.apache.org
> Subject: Re: Multiple resultsets in data mapper
>
> Thanks guys, maybe i wasn't clear enough. What i'd like to have is sql
> returning two tables. In table one up to hundreds of companies and in
> the second table the classifications for each (M:M). I've done it
> before so that i load the companies into a dictionary with id as a key
> and then add the classifications to each item in the dictionary. If
> i've understood correctly, this is not possible with ibatis? Lazy
> loading won't help me as i need to display everything at once, and the
> join method would lead to whole lot of data loading as there will be
> several similar collections within company. This is quite a central
> piece me the app, so i'd like to get it perform well.
>
> On 5/25/07, Nguyen, Tom <Tom.Nguyen@rels.info> wrote:
> > Some documentation here:
> > http://ibatisnet.sourceforge.net/DevGuide.html#d0e997
> >
> >
> >
> > Regards,
> >
> >
> > Tom Nguyen
> > Sr. Developer
> > tom.nguyen@rels.info <mailto:tom.nguyen@rels.info>
> >
> >
> >
> > ________________________________
> >
> > From: chook rib [mailto:chookrib@gmail.com]
> > Sent: Friday, May 25, 2007 9:41 AM
> > To: user-cs@ibatis.apache.org
> > Subject: Re: Multiple resultsets in data mapper
> >
> >
> >
> > sorry, have a slip, this is right
> >
> > 	<resultMaps>
> > 	  <resultMap id="CompanyResult" class="Company">
> > 	   <result property="Id" column="CompanyId" />
> > 	   <result property="Name" column="CompanyName" />
> > 	   <result property="Classifications" column="CompanyId"
> > select="SelectClassifications" lazyLoad="true" />
> > 	  </resultMap>
> > 	  <resultMap id="ClassificationResult" class="Classification">
> > 	   <result property="Id" column="ClassificationId" />
> > 	   <result property="Name" column="ClassificationName" />
> > 	  </resultMap>
> > 	 </resultMaps>
> >
> > 	 <statements>
> > 	  <select id="SelectCompanies" resultMap="CompanyResult">
> > 	   SELECT CompanyId, CompanyName FROM Company
> > 	  </select>
> >
> > 	  <select id="SelectClassifications" parameterClass="int"
> > resultMap="ClassificationResult">
> > 	   SELECT CompanyId, ClassificationId, ClassificationName FROM
> > CompanyClassification INNER JOIN Classification ON
> > CompanyClassification.ClassificationId=Classification.ClassificationId;
> > 	  </select>
> > 	</statements>
> > 	
> >
> >
> >
> ************************************************************************************
> > This e-mail message and any files transmitted herewith, are intended
> solely
> > for the
> > use of the individual(s) addressed and may contain confidential,
> proprietary
> > or
> > privileged information.  If you are not the addressee indicated in this
> > message
> > (or responsible for delivery of this message to such person) you may not
> > review,
> > use, disclose or distribute this message or any files transmitted
> herewith.
> > If you
> > receive this message in error, please contact the sender by reply e-mail
> and
> > delete
> > this message and all copies of it from your system.
> >
> ************************************************************************************
> >
> ************************************************************************************
> This e-mail message and any files transmitted herewith, are intended solely
> for the
> use of the individual(s) addressed and may contain confidential, proprietary
> or
> privileged information.  If you are not the addressee indicated in this
> message
> (or responsible for delivery of this message to such person) you may not
> review,
> use, disclose or distribute this message or any files transmitted herewith.
> If you
> receive this message in error, please contact the sender by reply e-mail and
> delete
> this message and all copies of it from your system.
> ************************************************************************************
>

Mime
View raw message