Basically the idea is like this: You have a customer object. Each customer has a company object. When you query your customers and your ORM (iBatis,Nhibernate,etc) is loading your objects, for each customer it makes another query to get their company object. You have have a lot of extra queries generated. You make one query for customers and if you get 50 customers, you then make 50 other queries to get each customer's company object. This is known as the 1+n select problem.
The solution is to either turn on lazy loading, which means the ORM layer will not retrieve the company object unless the code actually tries to access it, or to turn on a join so that the one query for customers includes the company data and the ORM can load the object completely with just one query. -----Original Message----- From: Miika Mäkinen [mailto:[EMAIL PROTECTED] Sent: Thursday, May 24, 2007 3:56 PM To: [email protected] Subject: Re: Multiple resultsets in data mapper just fyi, the examples i gave are really simplified. In the actual model the parent will have multiple childrenlists and the objects more properties. Excuse my ignorance, but what is n + 1 select problem? On 5/24/07, Clough, Samuel (USPC.PRG.Atlanta) <[EMAIL PROTECTED]> wrote: > Off hand, I'd say look at the methods for loading complex types and > strategies to avoid what's known as the "N + 1 select" problem. I don't > think multiple recordsets is your best solution if I understand your > situation properly. > > _____ > > From: Miika Mäkinen [mailto:[EMAIL PROTECTED] > Sent: Wednesday, May 23, 2007 10:49 PM > To: [email protected] > Subject: Multiple resultsets in data mapper > > > Hi All, > I'm just getting into iBatis, and I'd like to if it can handle multiple > resultsets (.Net 2.0, Sql Server 2005) > > For example, I'd have an objects like (pseudo-code): > > class Company > { > int Id; > string Name; > List<Classification> Classifications; > } > > class Classification > { > int Id; > string Name; > } > > And a stored procedure would return 2 resultssets: > > SELECT CompanyId, CompanyName FROM Company; > SELECT CompanyId, ClassificationId, ClassificationName FROM > CompanyClassification INNER JOIN Classification ON > CompanyClassification.ClassificationId=Classification .ClassificationId; > > Can I some how map the 2nd returned table into "List<Classification> > Classifications" inside my "Company" object? > > Cheers, > Miika Mäkinen > -------------------------------------------------------- > > Princeton Retirement Group, Inc - Important Terms > This E-mail is not intended for distribution to, or use by, any person or > entity in any location where such distribution or use would be contrary to > law or regulation, or which would subject Princeton Retirement Group, Inc. > or any affiliate to any registration requirement within such location. > This E-mail may contain privileged or confidential information or may > otherwise be protected by work product immunity or other legal rules. No > confidentiality or privilege is waived or lost by any mistransmission. > Access, copying or re-use of information by non-intended or non-authorized > recipients is prohibited. If you are not an intended recipient of this > E-mail, please notify the sender, delete it and do not read, act upon, > print, disclose, copy, retain or redistribute any portion of this E-mail. > The transmission and content of this E-mail cannot be guaranteed to be > secure or error-free. Therefore, we cannot represent that the information in > this E-mail is complete, accurate, uncorrupted, timely or free of viruses, > and Princeton Retirement Group, Inc. cannot accept any liability for E-mails > that have been altered in the course of delivery. Princeton Retirement > Group, Inc. reserves the right to monitor, review and retain all electronic > communications, including E-mail, traveling through its networks and systems > (subject to and in accordance with local laws). If any of your details are > incorrect or if you no longer wish to receive mailings such as this by > E-mail please contact the sender by reply E-mail. > > -------------------------------------------------------- > -------------------------------------------------------- Princeton Retirement Group, Inc - Important Terms This E-mail is not intended for distribution to, or use by, any person or entity in any location where such distribution or use would be contrary to law or regulation, or which would subject Princeton Retirement Group, Inc. or any affiliate to any registration requirement within such location. This E-mail may contain privileged or confidential information or may otherwise be protected by work product immunity or other legal rules. No confidentiality or privilege is waived or lost by any mistransmission. Access, copying or re-use of information by non-intended or non-authorized recipients is prohibited. If you are not an intended recipient of this E-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute any portion of this E-mail. The transmission and content of this E-mail cannot be guaranteed to be secure or error-free. Therefore, we cannot represent that the information in this E-mail is complete, accurate, uncorrupted, timely or free of viruses, and Princeton Retirement Group, Inc. cannot accept any liability for E-mails that have been altered in the course of delivery. Princeton Retirement Group, Inc. reserves the right to monitor, review and retain all electronic communications, including E-mail, traveling through its networks and systems (subject to and in accordance with local laws). If any of your details are incorrect or if you no longer wish to receive mailings such as this by E-mail please contact the sender by reply E-mail. --------------------------------------------------------

