ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Bennett" <mark.benn...@ncmail.net>
Subject RE: Can DAO calls be in a constructor...
Date Wed, 23 Feb 2005 14:13:48 GMT
Yah. Anad Fida was asking before about how to use queryForMap with column
parameters in a Complex Property.  Branon Goodin told him that it wasn't
possible.  His suggestion was to "query your accounts first and then iterate
through the list using the queryForMap."  However in my case if my first
Complex Property result pulls back a tree I thought that it would be a pain
traverse it to decorate it with the maps that I wish Complex Property could
have done it the first place.  I don't disagree with 1), I just didn't like
any of the other workarounds I came up with.

Mark


-----Original Message-----
From: Clinton Begin [mailto:clinton.begin@gmail.com]
Sent: Tuesday, February 22, 2005 9:09 PM
To: ibatis-user-java@incubator.apache.org
Subject: Re: Can DAO calls be in a constructor...


Two things:

1) Thats' an absolutely horrible design.  Domain classes should not
call or depend on the DAO layer in any way.

2) You may have hit a limitation of the DB2 driver, possibly multiple
statements may not be open at the same time on a single connection.

No matter what, you should probably rethink that design.

Cheers,
Clinton


On Tue, 22 Feb 2005 16:49:31 -0500, Mark Bennett
<mark.bennett@ncmail.net> wrote:
> Can DAO calls be in a constructor if it is an object created by a Complex
> Property?
>
> First I know this is risky because you might encounter recursion.  But if
no
> cycle is created, then is this possible at all?
>
>   <resultMap id="juvenileResult" class="juvenile">
>     <result property="someBean.myBean" column="MYCOLUMN"/>
>   </resultMap>
>
> class MyBean {
>         private static ProfileService profileService =
> ProfileService.getInstance();
>         public MyBean() {
>                 // *** This will cause another iBatis call while other is
still in
> progress ***
>                 List list = profileService.getListOfSuff(1);
>         }
> }
>
> Mark
>
> <Feb 22, 2005 4:36:41 PM EST> <Error> <HTTP>
> <[WebAppServletContext(5788681,NCJOIN,/NCJOIN)] Servlet failed with
> Exception
> com.ibatis.dao.client.DaoException: Failed to execute queryForObject - id
> [getJuvenile], parameterObject [20210].  Cause:
> com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in ncjoin/persistence/sqlmapdao/sql/Profile.xml.
> --- The error occurred while applying a result map.
> --- Check the Profile.juvenileResult.
> --- The error happened while setting a property on the result object.
> --- Cause: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E
> Function sequence error. SQLSTATE=HY010
> Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E
> Function sequence error. SQLSTATE=HY010
> Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in ncjoin/persistence/sqlmapdao/sql/Profile.xml.
> --- The error occurred while applying a result map.
> --- Check the Profile.juvenileResult.
> --- The error happened while setting a property on the result object.
> --- Cause: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E
> Function sequence error. SQLSTATE=HY010
> Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E
> Function sequence error. SQLSTATE=HY010
>         at
>
com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForObject(SqlMapDaoTem
> plate.java:164)
>         at
>
ncjoin.persistence.sqlmapdao.ProfileSqlMapDao.getJuvenile(ProfileSqlMapDao.j
> ava:22)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at com.ibatis.dao.engine.impl.DaoProxy.invoke(DaoProxy.java:72)
>         at $Proxy141.getJuvenile(Unknown Source)
>         at
ncjoin.service.ProfileService.getJuvenile(ProfileService.java:36)
>         at
>
ncjoin.main.servlet.RequestProcessor.processActionPerform(RequestProcessor.j
> ava:54)
>         at
>
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
>         at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
>         at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :263)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :200)
>         at
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> ntext.java:2390)
>         at
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> :1959)
>         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
> Caused by:
> com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in ncjoin/persistence/sqlmapdao/sql/Profile.xml.
> --- The error occurred while applying a result map.
> --- Check the Profile.juvenileResult.
> --- The error happened while setting a property on the result object.
> --- Cause: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E
> Function sequence error. SQLSTATE=HY010
> Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E
> Function sequence error. SQLSTATE=HY010
>         at
>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWith
> Callback(GeneralStatement.java:180)
>         at
>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForO
> bject(GeneralStatement.java:99)
>         at
>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx
> ecutorDelegate.java:561)
>         at
>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx
> ecutorDelegate.java:536)
>         at
>
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSession
> Impl.java:97)
>         at
>
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientIm
> pl.java:69)
>         at
>
com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForObject(SqlMapDaoTem
> plate.java:162)
>         at
>
ncjoin.persistence.sqlmapdao.ProfileSqlMapDao.getJuvenile(ProfileSqlMapDao.j
> ava:22)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at com.ibatis.dao.engine.impl.DaoProxy.invoke(DaoProxy.java:72)
>         at $Proxy141.getJuvenile(Unknown Source)
>         at
ncjoin.service.ProfileService.getJuvenile(ProfileService.java:36)
>         at
>
ncjoin.main.servlet.RequestProcessor.processActionPerform(RequestProcessor.j
> ava:54)
>         at
>
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
>         at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
>         at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :263)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :200)
>         at
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> ntext.java:2390)
>         at
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> :1959)
>         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
> Caused by:
> COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E  Function
sequence
> error. SQLSTATE=HY010
>         at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown
> Source)
>         at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown
> Source)
>         at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown
> Source)
>         at COM.ibm.db2.jdbc.app.DB2ResultSet.next(Unknown Source)
>         at
>
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.jav
> a:353)
>         at
>
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java
> :179)
>         at
>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(
> GeneralStatement.java:200)
>         at
>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWith
> Callback(GeneralStatement.java:168)
>         at
>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForO
> bject(GeneralStatement.java:99)
>         at
>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx
> ecutorDelegate.java:561)
>         at
>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx
> ecutorDelegate.java:536)
>         at
>
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSession
> Impl.java:97)
>         at
>
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientIm
> pl.java:69)
>         at
>
com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForObject(SqlMapDaoTem
> plate.java:162)
>         at
>
ncjoin.persistence.sqlmapdao.ProfileSqlMapDao.getJuvenile(ProfileSqlMapDao.j
> ava:22)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at com.ibatis.dao.engine.impl.DaoProxy.invoke(DaoProxy.java:72)
>         at $Proxy141.getJuvenile(Unknown Source)
>         at
ncjoin.service.ProfileService.getJuvenile(ProfileService.java:36)
>         at
>
ncjoin.main.servlet.RequestProcessor.processActionPerform(RequestProcessor.j
> ava:54)
>         at
>
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
>         at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
>         at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :263)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :200)
>         at
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> ntext.java:2390)
>         at
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> :1959)
>         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >
>
>



Mime
View raw message