You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by John Chien <jo...@ncmail.net> on 2005/09/28 22:27:14 UTC
N+ 1 selects
Dear Sir:
I follow the FAQ to fix the N+1 selects, However, I continue get the
compilation error.
My xml looks like:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<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"
groupBy="key">
<result property="key" column="key" />
<result property="value" resultMap="EhsInspector.ehsInspectorsMap"/>
</resultMap>
<resultMap id="ehsInspectorsMap" class="ehsInspectors">
<result property="id" column="id"
jdbcType="NUMBER" javaType="java.lang.String" />
<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 DISTINCT
EHS_ID as key,
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
GROUP BY EHS_ID
</select>
</sqlMap>
If you can help me, I will be appreciated.
Thanks,
John Chien
Re: N+ 1 selects
Posted by Larry Meadors <la...@gmail.com>.
Give us a stack trace, too, please.
Larry
On 9/28/05, John Chien <jo...@ncmail.net> wrote:
> Dear Sir:
>
> I follow the FAQ to fix the N+1 selects, However, I continue get the
> compilation error.
> My xml looks like:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>
> <!DOCTYPE sqlMap
> PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
> "http://www.ibatis.com/dtd/sql-map-2.dtd">
>
> <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"
> groupBy="key">
> <result property="key" column="key" />
> <result property="value" resultMap="EhsInspector.ehsInspectorsMap"/>
> </resultMap>
>
> <resultMap id="ehsInspectorsMap" class="ehsInspectors">
> <result property="id" column="id"
> jdbcType="NUMBER" javaType="java.lang.String" />
> <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 DISTINCT
> EHS_ID as key,
> 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
> GROUP BY EHS_ID
> </select>
>
> </sqlMap>
>
> If you can help me, I will be appreciated.
>
> Thanks,
>
> John Chien
>
>
>
Array as parameter class
Posted by John Chien <jo...@ncmail.net>.
I would like to pass an array of String or a class that has an property
that is an array of String or Bean into the SqlMap query statement
as a parameter class. How can I reprsent it ?
Suppose the class is
public class Criteria {
private String[] a;
private List b; // which contains list of StringBean[]
....................................
}
public class DummyBean {
private StringBean[] c;
}
public class StringBean {
private String d;
}
and the sqlmap definition is:
<statement id="getEhsInspectorsAND" parameterClass="criteria"
resultMap="getEhsInspectorsMapAND">
SELECT
EHS_ID as id,
EHS_DUMMY as dummy
FROM ehs_table
WHERE EHS_ID = #a[0]# AND EHS_DUMMY=#b[1].c.d#
ORDER BY id
</statement>
Can I write the SqlMap in this way ? or What should I do ?
If I just pass in the String[], what can I do ?
String[] f;
<statement id="getEhsInspectorsAND" parameterClass="java.lang.String[]"
resultMap="getEhsInspectorsMapAND">
SELECT
EHS_ID as id,
FROM ehs_table
WHERE EHS_ID = #value[0]#
ORDER BY id
</statement>
Thanks,
John Chien
Re: N+ 1 selects
Posted by Larry Meadors <la...@gmail.com>.
Ohhh, OK.
That really has nothing to do with the n+1 problem (which is for
solving parent-child relationship issues...in databases).
You want to use queryForMap(queryName, parmBean, keyPropName) instead.
Larry
On 9/30/05, John Chien <jo...@ncmail.net> wrote:
>
> 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 result[@resultMap]
> 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 <jo...@ncmail.net> 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
>
>
>
Re: N+ 1 selects
Posted by John Chien <jo...@ncmail.net>.
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 result[@resultMap]
> 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* <john.chien@ncmail.net
> <ma...@ncmail.net>> 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 $B2<8a(B02$B;~(B42$BJ,(B36$BIC(B 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
>
>
Re: N+ 1 selects
Posted by Clinton Begin <cl...@gmail.com>.
Looks to me like you're:
1) Using an older version of iBATIS or at least an incorrect DTD reference
that does not support result[@resultMap]
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 <jo...@ncmail.net> 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
>
Re: N+ 1 selects
Posted by John Chien <jo...@ncmail.net>.
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
RE: N+ 1 selects
Posted by Jean-Francois Poilpret <jf...@hcm.vnn.vn>.
Hello John,
As far as I can see in your xml excerpt, you are not using the "groupBy"
feature of SqlMaps to avoid the N+1 select problem.
What you are doing in that example is using the SQL "GROUP BY" clause which
is completely different from the SqlMaps N+1 solution (maybe it should be
renamed to avoid confusion?)
In your select statement you put a GROUP BY clause, but you did not put any
aggregate in the selected columns (eg, MAX, MIN, SUM...) which is forbidden
in SQL, I think the error you got is an error returned by your SQL engine
about that.
In addition, did you understand clearly what the "N+1" problem is about? In
your sample, you select from exactly ONE table, so the "N+1" problem cannot
occur here! You ought to read deeper the SqlMap documentation, I guess.
Hope this helps
Jean-Francois
-----Original Message-----
From: John Chien [mailto:john.chien@ncmail.net]
Sent: Thursday, September 29, 2005 3:27 AM
To: user-java@ibatis.apache.org
Subject: N+ 1 selects
Dear Sir:
I follow the FAQ to fix the N+1 selects, However, I continue get the
compilation error.
My xml looks like:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<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"
groupBy="key">
<result property="key" column="key" />
<result property="value" resultMap="EhsInspector.ehsInspectorsMap"/>
</resultMap>
<resultMap id="ehsInspectorsMap" class="ehsInspectors">
<result property="id" column="id"
jdbcType="NUMBER" javaType="java.lang.String" />
<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 DISTINCT
EHS_ID as key,
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
GROUP BY EHS_ID
</select>
</sqlMap>
If you can help me, I will be appreciated.
Thanks,
John Chien