Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 5322 invoked from network); 19 May 2009 07:47:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 May 2009 07:47:10 -0000 Received: (qmail 11409 invoked by uid 500); 19 May 2009 07:47:09 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 11391 invoked by uid 500); 19 May 2009 07:47:09 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 11383 invoked by uid 99); 19 May 2009 07:47:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 May 2009 07:47:09 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 May 2009 07:46:59 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1M6K22-0005mZ-KX for user-java@ibatis.apache.org; Tue, 19 May 2009 00:46:38 -0700 Message-ID: <23611347.post@talk.nabble.com> Date: Tue, 19 May 2009 00:46:38 -0700 (PDT) From: Mike_ To: user-java@ibatis.apache.org Subject: Re: Mapping of a Set with enums In-Reply-To: <8eed5c5b0905181452l5ebc5d19qd7f95aa0aa4e2d0b@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: mail.micke@gmail.com References: <8eed5c5b0905181040v4338278eq1257c61188dd2c85@mail.gmail.com> <10268b3e0905181054p44c93833m4f43c2226558e296@mail.gmail.com> <8eed5c5b0905181452l5ebc5d19qd7f95aa0aa4e2d0b@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Thanks for the help! Having the secondMap return strings and moving the typehandler to the result element in the first resultMap worked perfectly. Just not very easy to figure out, I've done it the way I initially tried with JavaBeans before which worked fine. Thanks again, Micke Mike_ wrote: > > Hi > > I have a typehandler for the enum in the second result map which is > referenced from the CounterpartyHedgeVOResult result map. > > Do you mean that I should try having the second result map just return > strings, and change the line in the first result map to this? : > > property="creditEvents" > typeHandler="hedge.dao.CreditEventEnumReadOnlyTypeHandler"/> > > I'll give it a go tomorrow when I'm at work. > > Thanks, > micke > > 2009/5/18 DelGurth > >> On Mon, May 18, 2009 at 7:40 PM, Mikael Andersson >> wrote: >> > Hi >> > >> > I'm having problems mapping to a property which is a Set of java5 >> enums. >> > >> > I have a class CounterpartyHedgeVO which has the property creditEvents >> which >> > is a Set. >> > >> > Not sure what the problem is but I'm guessing that iBATIS tries to >> treat >> the >> > Enum like a POJO and fails to create it since there isn't a public >> > constructor. Or? >> > >> > Any help would be really appreciated. >> > >> > My current sqlmap (omitted the typeAlias definitions): >> > >> > > > groupBy="refNo"> >> > >> > >> > > > property="counterpartyCode"/> >> > > > property="tradeBook"/> >> > >> > > > property="creditEvents"/> >> > >> > >> > >> > > > typeHandler="hedge.dao.CreditEventEnumReadOnlyTypeHandler"/> >> > >> > >> > Stack trace: >> > --- The error occurred in ibatis/sqlmap-map-cds-hedge.xml. >> > --- The error occurred while applying a result map. >> > --- Check the CDS_HEDGE.CreditEventEnumResult. >> > --- The error occured while instantiating the result object >> > --- Cause: java.lang.RuntimeException: JavaBeansDataExchange could not >> > instantiate result class. Cause: java.lang.InstantiationException: >> > hedge.interfaces.CreditEventEnum >> > at >> > >> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123) >> > at >> > >> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:615) >> > at >> > >> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589) >> > at >> > >> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118) >> > at >> > >> org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:298) >> > at >> > >> org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209) >> > ... 40 more >> > Caused by: java.lang.RuntimeException: JavaBeansDataExchange could not >> > instantiate result class. Cause: java.lang.InstantiationException: >> > hedge.interfaces.CreditEventEnum >> > at >> > >> com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange.setData(JavaBeanDataExchange.java:108) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:373) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setNestedResultMappingValue(BasicResultMap.java:449) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.applyNestedResultMap(BasicResultMap.java:396) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:382) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:64) >> > at >> > >> com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:382) >> > at >> > >> com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:301) >> > at >> > >> com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:283) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173) >> > ... 46 more >> > Caused by: java.lang.InstantiationException: >> > hedge.interfaces.CreditEventEnum >> > at java.lang.Class.newInstance0(Class.java:340) >> > at java.lang.Class.newInstance(Class.java:308) >> > at >> com.ibatis.common.resources.Resources.instantiate(Resources.java:294) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil.createObjectInternally(ResultObjectFactoryUtil.java:127) >> > at >> > >> com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil.createObjectThroughFactory(ResultObjectFactoryUtil.java:95) >> > at >> > >> com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange.setData(JavaBeanDataExchange.java:106) >> > ... 56 more >> > >> > Cheers, >> > Micke >> >> I think you will need to create a typehandler so iBATIS can work with >> your >> Enum. >> >> See: >> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+a+Custom+Type+Handler+with+complex+property+or+Type+Safe+Enumeration >> >> Regards, >> Wessel >> > > -- View this message in context: http://www.nabble.com/Mapping-of-a-Set-with-enums-tp23602196p23611347.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com.