Return-Path: Mailing-List: contact ibatis-user-java-help@incubator.apache.org; run by ezmlm Delivered-To: mailing list ibatis-user-java@incubator.apache.org Received: (qmail 99950 invoked by uid 99); 10 Dec 2004 18:22:11 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from 66-207-66-79.black.dmt.ntelos.net (HELO palaka.bullwip.com) (66.207.66.79) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 10 Dec 2004 10:22:09 -0800 Received: from gen2tek007 (gen2tek-007.bullwip.com [192.168.0.7]) by palaka.bullwip.com (8.12.10/8.12.10) with SMTP id iBAIJqYG017193 for ; Fri, 10 Dec 2004 13:19:53 -0500 (EST) Reply-To: From: "Jerome Jacobsen" To: Subject: RE: Avoiding N+1 with complex HashMap properties. Date: Fri, 10 Dec 2004 13:22:02 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.4 (palaka.bullwip.com [192.168.5.23]); Fri, 10 Dec 2004 13:22:03 -0500 (EST) X-Spam-Flag: NO X-Scanned-By: milter-spamc/0.25.321 (palaka.bullwip.com [192.168.5.23]); Fri, 10 Dec 2004 13:19:56 -0500 X-Spam-Status: NO, hits=-2.80 required=4.00 X-Spam-Level: X-Spam-Report: Spam detection software, running on the system "broga.bullwip.com", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see postmaster@gentootech.com for details. ____ Content preview: Darn typo! Option 2 should say: HashMap customer = customerDao.getCustomer(id); HashMap address = customer.get("address"); out.println("customer state = " + address.get("state")); customer.get("address") instead of customerDao.get("address") [...] ____ Content analysis details: (-2.8 points, 4.0 required) ____ pts rule name description ---- ---------------------- -------------------------------------------------- -2.8 ALL_TRUSTED Did not pass through any untrusted hosts ____ X-Virus-Checked: Checked Darn typo! Option 2 should say: HashMap customer = customerDao.getCustomer(id); HashMap address = customer.get("address"); out.println("customer state = " + address.get("state")); customer.get("address") instead of customerDao.get("address") We're getting the 'address' HashMap from the 'customer' HashMap. > -----Original Message----- > From: Jerome Jacobsen [mailto:jerome.jacobsen@gentootech.com] > Sent: Friday, December 10, 2004 12:49 PM > To: ibatis-user-java@incubator.apache.org > Subject: RE: Avoiding N+1 with complex HashMap properties. > > > Just to be clear, here are examples of what I'm talking about. > > Option 1: Single hashmap with indexed property style keys. > > HashMap customer = customerDao.getCustomer(id); > out.println("customer state = " + customer.get("address.state")); > > Option 2: Nested hashmaps. > > HashMap customer = customerDao.getCustomer(id); > HashMap address = customerDao.get("address"); > out.println("customer state = " + address.get("state")); > > > I have no preference as to which way is supported, as long as: > - The exception doesn't occur. > - I can access the properties using the 'indexed property' > style in JSP. > > I'm not sure how JSTL/JSP would handle the nested HashMap versus > handling the single HashMap. > > In JSP not sure if I can do this for both implementations > above: > > Customer State = > > If JSP/JSTL only supports one of these implementation options > then that would be my preference for ibatis too. > > Regards, > > Jerome > > > -----Original Message----- > > From: Clinton Begin [mailto:clinton.begin@gmail.com] > > Sent: Friday, December 10, 2004 10:09 AM > > To: jerome.jacobsen@gentootech.com > > Cc: ibatis-user-java@incubator.apache.org > > Subject: Re: Avoiding N+1 with complex HashMap properties. > > > > > > Tough call. Some people want it stored as a single property (e.g. > > imagine the key is a classname), and others want it stored nested. > > > > Currently, as you've discovered, it's not nested. > > > > I would suggest that if you have a complex object model, then you > > should model it using JavaBeans. Maps are very loose, unpredictable > > and limited. > > > > Cheers, > > Clinton > > > > > > On Fri, 10 Dec 2004 10:03:16 -0500, Jerome Jacobsen > > wrote: > > > Hello, > > > > > > I'm using SQL Maps 2.08. I was hoping I could do the following > > > but I get a ProbeException. Should this be supported? > > > > > > > > class="java.util.HashMap"> > > > > > column="CUSTOMER_NUMBER" > > > columnIndex="1"/> > > > > > column="CATEGORY_ID" > > > columnIndex="2"/> > > > > > column="PARENT_CATEGORY_ID" > > > columnIndex="3"/> > > > > > column="CATEGORY_DESC" > > > columnIndex="4"/> > > > ... > > > > > > > > > > > resultMap="get-customer-period-result"> > > > SELECT CPS.CUSTOMER_NUMBER, > > > PC.CATEGORY_ID, > > > PC.PARENT_CATEGORY_ID, > > > PC.DESCRIPTION AS CATEGORY_DESC, > > > PC.SEQUENCE AS CATEGORY_SEQUENCE, > > > ... > > > FROM CUSTOMER_PERIOD_SUMMARY CPS, PRODUCT_CATEGORY PC, > > SALES_PERIOD SP > > > WHERE CPS.CUSTOMER_NUMBER = #value# > > > AND CPS.CATEGORY_ID = PC.CATEGORY_ID > > > AND CPS.PERIOD_ID = SP.PERIOD_ID > > > ORDER BY CATEGORY_SEQUENCE > > > > > > > > > I was hoping that sqlmaps would store the 'category.id', > > > 'category.parentId', 'category.description' either in a nested > > > HashMap (key of 'category') or store the values in the top > > > level HashMap with those keys ('category.id', etc.) > > > > > > However neither case appears to happen and I get the > > > exception below. I realize that I can map the complex > > > properties with separate selects but I want to avoid the > > > N+1 query problem. So I do the join instead. > > > > > > com.ibatis.common.beans.ProbeException: There is no WRITEABLE > > property named > > > 'id' in class 'java.lang.Object' > > > at > > com.ibatis.common.beans.ClassInfo.getSetter(ClassInfo.java:146) > > > at > > > > > com.ibatis.common.beans.ComplexBeanProbe.setProperty(ComplexBeanPr > > obe.java:3 > > > 34) > > > at > > > > > com.ibatis.common.beans.ComplexBeanProbe.setObject(ComplexBeanProb > > e.java:231 > > > ) > > > at > > com.ibatis.common.beans.GenericProbe.setObject(GenericProbe.java:69) > > > at > > > > > com.ibatis.sqlmap.engine.exchange.ComplexDataExchange.setData(Comp > > lexDataExc > > > hange.java:87) > > > at > > > > > com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultOb > > jectValues > > > (BasicResultMap.java:231) > > > at > > > > > com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.hand > > leResultOb > > > ject(RowHandlerCallback.java:63) > > > at > > > > > com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlEx > > ecutor.jav > > > a:350) > > > at > > > > > com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExe > > cutor.java > > > :179) > > > at > > > > > com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExe > > cuteQuery( > > > GeneralStatement.java:200) > > > at > > > > > com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.execut > > eQueryWith > > > Callback(GeneralStatement.java:168) > > > at > > > > > com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.execut > > eQueryForL > > > ist(GeneralStatement.java:118) > > > at > > > > > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList( > > SqlMapExec > > > utorDelegate.java:626) > > > at > > > > > com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList( > > SqlMapExec > > > utorDelegate.java:598) > > > at > > > > > com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMa > > pSessionIm > > > pl.java:107) > > > at > > > > > org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapCl > > ient(SqlMa > > > pClientTemplate.java:202) > > > at > > > > > org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMap > > ClientTemp > > > late.java:142) > > > at > > > > > org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithLis > > tResult(Sq > > > lMapClientTemplate.java:164) > > > at > > > > > org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(S > > qlMapClien > > > tTemplate.java:200) > > > at > > > > > com.giv.dashboard.dao.db.ibatis.SqlMapSalesStatisticsDAO.getCatego > > ryStatsFor > > > Customer(SqlMapSalesStatisticsDAO.java:28) > > > at > > > > > com.giv.dashboard.DashboardImpl.getCategorySummaries(DashboardImpl > > .java:42) > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > > at > > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm > > pl.java:39 > > > ) > > > at > > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc > > cessorImpl > > > .java:25) > > > at java.lang.reflect.Method.invoke(Method.java:324) > > > at > > > > > org.springframework.aop.support.AopUtils.invokeJoinpointUsingRefle > > ction(AopU > > > tils.java:295) > > > at > > > > > org.springframework.aop.framework.ReflectiveMethodInvocation.invok > > eJoinpoint > > > (ReflectiveMethodInvocation.java:154) > > > at > > > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proce > > ed(Reflect > > > iveMethodInvocation.java:121) > > > at > > > > > org.springframework.transaction.interceptor.TransactionInterceptor > > .invoke(Tr > > > ansactionInterceptor.java:56) > > > at > > > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proce > > ed(Reflect > > > iveMethodInvocation.java:143) > > > at > > > > > org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDyn > > amicAopPro > > > xy.java:174) > > > at $Proxy0.getCategorySummaries(Unknown Source) > > > at > > > > > com.giv.dashboard.web.spring.ViewCategoriesController.handleReques > > tInternal( > > > ViewCategoriesController.java:62) > > > at > > > > > org.springframework.web.servlet.mvc.AbstractController.handleReque > > st(Abstrac > > > tController.java:128) > > > at > > > > > org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter > > .handle(Si > > > mpleControllerHandlerAdapter.java:44) > > > at > > > > > org.springframework.web.servlet.DispatcherServlet.doService(Dispat > > cherServle > > > t.java:532) > > > at > > > > > org.springframework.web.servlet.FrameworkServlet.serviceWrapper(Fr > > ameworkSer > > > vlet.java:366) > > > at > > > > > org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkSe > > rvlet.java > > > :317) > > > at > javax.servlet.http.HttpServlet.service(HttpServlet.java:740) > > > at > javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > > > at > > > > > com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilt > > erChain.ja > > > va:65) > > > at > oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source) > > > at > > > > > com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRe > > questDispa > > > tcher.java:604) > > > at > > > > > com.evermind.server.http.ServletRequestDispatcher.forwardInternal( > > ServletReq > > > uestDispatcher.java:317) > > > at > > > > > com.evermind.server.http.HttpRequestHandler.processRequest(HttpReq > > uestHandle > > > r.java:790) > > > at > > > > > com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler > > .java:270) > > > at > > > > > com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler > > .java:112) > > > at > > > > > com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(Re > > leasableRe > > > sourcePooledExecutor.java:192) > > > at java.lang.Thread.run(Thread.java:534) > > > > > > > >