Clienton:

I want to get back a HaspMap that has keys and values.

Each key corresponds to different  id (EHS_ID),
Each value is a bean that has all the fields returned from query that corresponds to that id.

Normally, the query results in a list of bean. Each bean has all the fields selected in the query.

Since the EHS_ID is unique (primary key of the table), I would like to get back a HashMap that has
all the EHS_ID as its key and all the columns correspond to a specific key to be in a bean.

If you can help me in this subject, I will be very appreciate.

Thanks,

John Chien

Clinton Begin wrote:
Looks to me like you're:

1) Using an older version of iBATIS or at least an incorrect DTD reference that does not support [EMAIL PROTECTED]
2) You're using half of the N+1 selects solution....which will not do much for you. 

Perhaps ignore this problem for now, and instead state exactly what it is you're trying to do.  We'll start there and see if it leads to this problem again.

Cheers,
Clinton

On 9/29/05, John Chien <[EMAIL PROTECTED]> wrote:
Jean:

Thank you for your response.
That's my fault. My intention actually is not tries to do the N+1 selects, but have returned result putting into a bean.
This bean will be used as a property of another bean.

I do not know if my way of doing it is correct or not. Somehow it does not work

Following is my new try and the trace:

*****************************************************************************************
<sqlMap namespace="EhsInspector">

  <typeAlias alias="ehsInspectors" type="us.nc.state.enr.bets.util.EhsInspectorBean"/>
  <typeAlias alias="commonFinder"  type="us.nc.state.enr.bets.finder.CommonFinder" />

  <resultMap id="getEhsInspectorsANDMap" class="java.util.HashMap" >
      <result property="id"   column="id"  />
      <result property="value"  resultMap="EhsInspector.ehsInspectorsMap"/>                          <----- This is line 15
  </resultMap>
 
  <resultMap id="ehsInspectorsMap" class="ehsInspectors">
    <result property="last_name"         column="last_name"        jdbcType="VARCHAR" javaType="java.lang.String" />
    <result property="first_name"        column="first_name"       jdbcType="VARCHAR" javaType="java.lang.String" />
    <result property="middle_initial"    column="middle_initial"   jdbcType="VARCHAR" javaType="java.lang.String" />
    <result property="added_date"        column="added_date"       jdbcType="VARCHAR" javaType="java.lang.String" />
    <result property="last_update_date"  column="last_update_date" jdbcType="VARCHAR" javaType="java.lang.String" />
    <result property="last_update_user"  column="last_update_user" jdbcType="VARCHAR" javaType="java.lang.String" />
  </resultMap>
 
  <select id="getEhsInspectorsAND" parameterClass="commonFinder" resultMap="getEhsInspectorsANDMap">
 
      SELECT
            EHS_ID                           as id,
            EHS_NAME_LAST        as last_name,
            EHS_NAME_FIRST       as first_name,
            EHS_NAME_MI          as middle_initial,
            EHS_ADDED_DT         as added_date,
            EHS_LAST_UPDATE_DT   as last_update_date,
            EHS_LAST_UPDATE_USER as last_update_user
      FROM  EH.BETS_EHS_INSPECTOR
      ORDER BY EHS_ID
  </select>   
    
</sqlMap>
******************************************************************************************************

Trace:

<2005/9/29 下午02時42分36秒 GMT-05:00> <Error> <HTTP> <BEA-101216> <Servlet: "context" failed to preload on startup in Web application: "eh".
javax.servlet.ServletException: Error creating bean with name 'sqlMapClient' defined in resource [/WEB-INF/dataAccessContext-bets.xml] of ServletContext: Initialization of bean failed; nested exception is com.ibatis.sqlmap.client.SqlMapException: There was an error while building the SqlMap instance.
--- The error occurred in us/nc/state/enr/bets/dao/ibatis/maps/EhsInspectorFinder.xml.
--- The error occurred while loading the SQL Map resource.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: XML Parser Error.  Cause: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must bedeclared for element type "result".
Caused by: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must be declared for element type "result".
        at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:919)
        at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:883)
        at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:822)
        at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3333)
        at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3290)
        at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3276)
        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3259)
        at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:5949)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:862)
        at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2127)
        at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2168)
        at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2115)
        at weblogic.management.deploy.slave.SlaveDeployer$Application.setActivation(SlaveDeployer.java:3082)
        at weblogic.management.deploy.slave.SlaveDeployer.setActivationStateForAllApplications(SlaveDeployer.java:1751)
        at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:359)
        at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:229)
        at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:131)
        at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:966)
        at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:361)
        at weblogic.Server.main(Server.java:32)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in resource [/WEB-INF/dataAccessContext-bets.xml] of ServletContext: Initialization of bean failed; nested exception is
 com.ibatis.sqlmap.client.SqlMapException: There was an error while building the SqlMap instance.
--- The error occurred in us/nc/state/enr/bets/dao/ibatis/maps/EhsInspectorFinder.xml.
--- The error occurred while loading the SQL Map resource.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: XML Parser Error.  Cause: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must bedeclared for element type "result".
Caused by: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must be declared for element type "result".
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:300)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:205)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:230)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:284)
        at org.springframework.web.context.support.XmlWebApplicationContext.refresh(XmlWebApplicationContext.java:131)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:156)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:97)
        at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:80)
        at javax.servlet.GenericServlet.init(GenericServlet.java:258)
        at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1028)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
        at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:904)
        ... 19 more
Caused by: com.ibatis.sqlmap.client.SqlMapException: There was an error while building the SqlMap instance.
--- The error occurred in us/nc/state/enr/bets/dao/ibatis/maps/EhsInspectorFinder.xml.
--- The error occurred while loading the SQL Map resource.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: XML Parser Error.  Cause: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must bedeclared for element type "result".
Caused by: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must be declared for element type "result".
Caused by: com.ibatis.sqlmap.client.SqlMapException: XML Parser Error.  Cause: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must bedeclared for element type "result".
Caused by: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must be declared for element type "result".
        at com.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder.buildSqlMap(XmlSqlMapClientBuilder.java:214)
        at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:61)
        at org.springframework.orm.ibatis.SqlMapClientFactoryBean.afterPropertiesSet(SqlMapClientFactoryBean.java:109)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:287)
        ... 33 more
Caused by: com.ibatis.sqlmap.client.SqlMapException: XML Parser Error.  Cause: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must bedeclared for element type "result".
Caused by: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must be declared for element type "result".
        at com.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder.getDoc(XmlSqlMapClientBuilder.java:1286)
        at com.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder.parseSqlMapRef(XmlSqlMapClientBuilder.java:429)
        at com.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder.parseSqlMapConfig(XmlSqlMapClientBuilder.java:240)
        at com.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder.buildSqlMap(XmlSqlMapClientBuilder.java:210)
        ... 37 more
Caused by: org.xml.sax.SAXException: Error: URI=null Line=15: Attribute "resultMap" must be declared for element type "result".
        at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:281)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:206)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
        at com.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder.getDoc(XmlSqlMapClientBuilder.java:1283)
        ... 40 more

begin:vcard
fn:John Chien
n:Chien;John
email;internet:[EMAIL PROTECTED]
tel;work:919-715-2510
version:2.1
end:vcard

Reply via email to