melwong | 8 Feb 02:38 2009
Picon

java.sql.SQLException: Already closed.


-I'm using iBatis 2.3.4 and DBCP 1.2.2 on Tomcat 6
-When I start Tomcat and run my first request, things went fine
-Then I when i run my second request, error below happened
-My ibatis config file is attached

**********************************
ERROR LOG

java.sql.SQLException: Already closed.
                at
org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:84)
                at
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
                at
com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:81)
                at
com.ibatis.sqlmap.engine.transaction.TransactionManager.end(TransactionManager.java:93)
                at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:734)
                at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:176)
                at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:153)
              at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:835)
                at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:410)
                at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
(Continue reading)

Melvin Wong | 8 Feb 02:42 2009
Picon

java.sql.SQLException: Already closed.

But now I have a new prob.

 

-I'm using iBatis 2.3.4 and DBCP 1.2.2 on Tomcat 6

-When I start Tomcat and run my first request, things went fine

-Then I when i run my second request, error below happened

-My ibatis config file is attached

 

**********************************

ERROR LOG

 

java.sql.SQLException: Already closed.

                at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:84)

                at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)

                at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.close(JdbcTransaction.java:81)

                at com.ibatis.sqlmap.engine.transaction.TransactionManager.end(TransactionManager.java:93)

                at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:734)

                at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:176)

                at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:153)

              at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:835)

                at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:410)

                at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)

                at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:58)

                at my.com.justmobile.engine.SSUMEngine.log(SSUMEngine.java:408)

                at my.com.justmobile.engine.SSUMEngine.validate(SSUMEngine.java:292)

                at my.com.justmobile.engine.SSUMEngine.process(SSUMEngine.java:205)

                at my.com.justmobile.SSUMServlet.processRequest(SSUMServlet.java:145)

                at my.com.justmobile.SSUMServlet.doGet(SSUMServlet.java:242)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)

                at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:852)

                at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:584)

                at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)

                at java.lang.Thread.run(Thread.java:619)

 

Attached are my configurations files. I’m still waiting to discuss your rate. I’m open, let me know your thoughts.

 

 

Thank you for your time to read this email.

Mel

Attachment (SqlMapConfig.properties): application/octet-stream, 273 bytes
Attachment (ssum.properties): application/octet-stream, 1537 bytes
Attachment (SqlMapConfig.xml): text/xml, 2143 bytes
Ing. Jan Novotný | 8 Feb 10:11 2009
Picon

iBatis 3 roadmap

Hello everybody,

    I'm going to have a speech at czech university about iBatis and among the isssues I want to cover is, how the iBatis is perspective for you as a develeper. Originaly I had there a sentence: iBatis will improve more dynamically than widely spread standards can ever do (such as JDBC or JPA). This sentence was written 2 years ago, but I am not so sure now.
    When I look into http://opensource.atlassian.com/confluence/oss/display/IBATIS/iBATIS+3.0+Whiteboard, it has been long since it was seriously touched and I haven't found any other clue when or whether there is going to be iBatis 3. There is very small activity for 3.x version in Jira, thouhg there are some commits into iBatis 3 core (http://www.mail-archive.com/commits <at> ibatis.apache.org/). So can anyone give me any answer about iBatis 3, that I can spread further?

Cheers,
Jan

--
--------------------------------------------------------------
Ing. Jan Novotný
<at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at>
http://blog.novoj.net
Myšlenky dne otce Fura
--------------------------------------------------------------

Rob Sonke | 8 Feb 10:22 2009
Picon

Re: custom type handler w/ database-specific type

DO you need access to the DataSource or the Connection?

Rob

John Cartwright wrote:
> I think I've worked around this problem by explicitly specifying the 
> handler class w/in the in-line parameter map.
> Now I seem to have the problem of TypeHandler class needing access to 
> the DataSource...
>
> --john
>
>
> John Cartwright wrote:
>> Hello All,
>>
>> I'm trying to implement a custom type handler to support Oracle's
>> SDO_GEOMETRY type.  I've got it (apparently) working for retrieval of
>> data, but am having trouble w/ inserts into the database. Error says:
>>
>> org.springframework.jdbc.UncategorizedSQLException: SqlMapClient
>> operation; uncategorized SQLException for SQL []; SQL state [null];
>> error code [0];   --- The error occurred in 
>> gov/noaa/ngdc/mgg/ufn/Feature.xml.  --- The error occurred while 
>> applying a parameter map.  --- Check the 
>> Feature.insertShape-InlineParameterMap.  --- Check the parameter 
>> mapping for the 'geometry' property.  --- Cause: 
>> java.lang.NullPointerException; nested exception is
>> com.ibatis.common.jdbc.exception.NestedSQLException:   --- The error 
>> occurred in gov/noaa/ngdc/mgg/ufn/Feature.xml.  --- The error 
>> occurred while applying a parameter map.  --- Check the 
>> Feature.insertShape-InlineParameterMap.  --- Check the parameter 
>> mapping for the 'geometry' property.  --- Cause: 
>> java.lang.NullPointerException
>>
>> I'm registering a global type handler w/:
>>
>> <typeHandler
>> callback="gov.noaa.ngdc.mgg.ufn.dao.ibatis.SdoGeometryHandler"
>> javaType="com.vividsolutions.jts.geom.Geometry" 
>> jdbcType="SDO_GEOMETRY" />
>>
>>
>> and the inline parameter map for the "geometry" column uses:
>>
>> #geometry:SDO_GEOMETRY#
>>
>>
>> I've tried various other values for JDBC types: STRUCT, OTHER
>> w/o success.
>>
>> Can someone please help me understand a little better about the
>> connections between the the types in the parameter map and the
>> typehandler registration?
>>
>> Thanks!
>>
>> --john
>>

Rahul Saluja | 8 Feb 10:34 2009
Picon

RE: custom type handler w/ database-specific type

Hi John,

As far I can understand from your mail you exactly wish to know how to register your typehandlers for
parameter types in your sqlmap or parametermap well here is the example you can do this:

public class ArraysToStringTypeHandler implements TypeHandlerCallback
{
        private static LoggerIf log_ = LogFactory.getLoggerIf ( ArraysToStringTypeHandler.class.getName ( ) );

        public Object getResult(ResultGetter arg0) throws SQLException
        {
                // TODO Auto-generated method stub
                return null;
        }

        public void setParameter(ParameterSetter setter, Object parameter) throws SQLException
        {
                if (parameter == null) {
            log_.debug("[ArraysToString][setParameter] parameter is coming as NULL");
                        setter.setNull(Types.CHAR);
        } else {
                  //setter.setNull(Types.CHAR);
                log_.debug("[ArraysToString][setParameter] going to call ArraysToString(parameter) ");
                setter.setString(ArraysToString( parameter));
        }
                // TODO Auto-generated method stub

        }

        public Object valueOf(String arg0)
        {
                // TODO Auto-generated method stub
                return null;
        }

        private String ArraysToString(Object obj)
        {
                log_.debug("[ArraysToString][setParameter] inside ArraysToString(parameter) ");
                if ( obj == null)
                {
                        throw new IllegalArgumentException ("Could not convert null to a String value. " +
                        "Valid argument is an array of type I_U8 Only ");
                }
                else if (obj instanceof com.hns.hss.nmf.server.log.manager.gensrc.Common.I_U8 []  )
                {

                com.hns.hss.nmf.server.log.manager.gensrc.Common.I_U8 [] ourData = (
com.hns.hss.nmf.server.log.manager.gensrc.Common.I_U8 [])obj;
                        log_.debug("Array contents are of type ----> "+ourData.getClass().getComponentType());
                        int length = ourData.length;
                        log_.debug("so length of our data is " + length);

                        StringBuffer dataHolderSb = new StringBuffer();
                        dataHolderSb.append("{");
                        for(int i = 0 ;i<length ; i++)
                        {

                                dataHolderSb.append(ourData[i].getValue());
                                dataHolderSb.append(",");
                        }
                        dataHolderSb.append("}");
                        return dataHolderSb.toString();

                }
                else{
                        return null;
                }
                //return null;

        }
}

<insert id="ID "
                        parameterClass="com.yourcompany.Classname">
                                insert into TableName (wrongBsic0,oTargetCellUlQual,noTargetCellDlLevel,
                                  noTargetCellUlLevel)
                                values(nextval ('BSCCSALGOHOPM_SEQ'),
                        #wrongBsic0,handler=ArraysToStringTypeHandler#
                                #noTargetCellUlLevel.value#)
                        </insert>

Hope it helps.

Regards
Rahul Saluja

-----Original Message-----
From: Rob Sonke [mailto:rob <at> tigrou.nl]
Sent: Sunday, February 08, 2009 2:53 PM
To: user-java <at> ibatis.apache.org
Subject: Re: custom type handler w/ database-specific type

DO you need access to the DataSource or the Connection?

Rob

John Cartwright wrote:
> I think I've worked around this problem by explicitly specifying the
> handler class w/in the in-line parameter map.
> Now I seem to have the problem of TypeHandler class needing access to
> the DataSource...
>
> --john
>
>
> John Cartwright wrote:
>> Hello All,
>>
>> I'm trying to implement a custom type handler to support Oracle's
>> SDO_GEOMETRY type.  I've got it (apparently) working for retrieval of
>> data, but am having trouble w/ inserts into the database. Error says:
>>
>> org.springframework.jdbc.UncategorizedSQLException: SqlMapClient
>> operation; uncategorized SQLException for SQL []; SQL state [null];
>> error code [0];   --- The error occurred in
>> gov/noaa/ngdc/mgg/ufn/Feature.xml.  --- The error occurred while
>> applying a parameter map.  --- Check the
>> Feature.insertShape-InlineParameterMap.  --- Check the parameter
>> mapping for the 'geometry' property.  --- Cause:
>> java.lang.NullPointerException; nested exception is
>> com.ibatis.common.jdbc.exception.NestedSQLException:   --- The error
>> occurred in gov/noaa/ngdc/mgg/ufn/Feature.xml.  --- The error
>> occurred while applying a parameter map.  --- Check the
>> Feature.insertShape-InlineParameterMap.  --- Check the parameter
>> mapping for the 'geometry' property.  --- Cause:
>> java.lang.NullPointerException
>>
>> I'm registering a global type handler w/:
>>
>> <typeHandler
>> callback="gov.noaa.ngdc.mgg.ufn.dao.ibatis.SdoGeometryHandler"
>> javaType="com.vividsolutions.jts.geom.Geometry"
>> jdbcType="SDO_GEOMETRY" />
>>
>>
>> and the inline parameter map for the "geometry" column uses:
>>
>> #geometry:SDO_GEOMETRY#
>>
>>
>> I've tried various other values for JDBC types: STRUCT, OTHER
>> w/o success.
>>
>> Can someone please help me understand a little better about the
>> connections between the the types in the parameter map and the
>> typehandler registration?
>>
>> Thanks!
>>
>> --john
>>
The information contained in this e-mail is private & confidential and may also be legally privileged. If
you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or
disclose the contents of this message to anyone.

Rahul Saluja | 8 Feb 10:36 2009
Picon

RE: custom type handler w/ database-specific type

And one more thing which I forgot to mention don't forget to declare your typehandler with alias in you
sqlmapconfig file in following manner

<typeAlias alias="ArraysToStringTypeHandler"
type="com.hns.hss.nmf.server.log.manager.util.ArraysToStringTypeHandler" />

Regards
Rahul Saluja

-----Original Message-----
From: Rob Sonke [mailto:rob <at> tigrou.nl]
Sent: Sunday, February 08, 2009 2:53 PM
To: user-java <at> ibatis.apache.org
Subject: Re: custom type handler w/ database-specific type

DO you need access to the DataSource or the Connection?

Rob

John Cartwright wrote:
> I think I've worked around this problem by explicitly specifying the
> handler class w/in the in-line parameter map.
> Now I seem to have the problem of TypeHandler class needing access to
> the DataSource...
>
> --john
>
>
> John Cartwright wrote:
>> Hello All,
>>
>> I'm trying to implement a custom type handler to support Oracle's
>> SDO_GEOMETRY type.  I've got it (apparently) working for retrieval of
>> data, but am having trouble w/ inserts into the database. Error says:
>>
>> org.springframework.jdbc.UncategorizedSQLException: SqlMapClient
>> operation; uncategorized SQLException for SQL []; SQL state [null];
>> error code [0];   --- The error occurred in
>> gov/noaa/ngdc/mgg/ufn/Feature.xml.  --- The error occurred while
>> applying a parameter map.  --- Check the
>> Feature.insertShape-InlineParameterMap.  --- Check the parameter
>> mapping for the 'geometry' property.  --- Cause:
>> java.lang.NullPointerException; nested exception is
>> com.ibatis.common.jdbc.exception.NestedSQLException:   --- The error
>> occurred in gov/noaa/ngdc/mgg/ufn/Feature.xml.  --- The error
>> occurred while applying a parameter map.  --- Check the
>> Feature.insertShape-InlineParameterMap.  --- Check the parameter
>> mapping for the 'geometry' property.  --- Cause:
>> java.lang.NullPointerException
>>
>> I'm registering a global type handler w/:
>>
>> <typeHandler
>> callback="gov.noaa.ngdc.mgg.ufn.dao.ibatis.SdoGeometryHandler"
>> javaType="com.vividsolutions.jts.geom.Geometry"
>> jdbcType="SDO_GEOMETRY" />
>>
>>
>> and the inline parameter map for the "geometry" column uses:
>>
>> #geometry:SDO_GEOMETRY#
>>
>>
>> I've tried various other values for JDBC types: STRUCT, OTHER
>> w/o success.
>>
>> Can someone please help me understand a little better about the
>> connections between the the types in the parameter map and the
>> typehandler registration?
>>
>> Thanks!
>>
>> --john
>>
The information contained in this e-mail is private & confidential and may also be legally privileged. If
you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or
disclose the contents of this message to anyone.

Kai Grabfelder | 8 Feb 11:17 2009
Picon

Re: iBatis 3 roadmap

This is not really about iBATIS 3 but about the improvements of iBATIS 2. In my opinion it is perfect just the
way it is currently. So iBATIS 2 is not dead or no longer loved by it's devs - it's just very very mature.

Regarding iBATIS 3: I guess Clinton will be able to answer your questions...

Regards

Kai

--- Original Nachricht ---
Absender: Ing. Jan Novotný
Datum: 08.02.2009 10:11
> Hello everybody,
> 
>     I'm going to have a speech at czech university about iBatis and among
> the isssues I want to cover is, how the iBatis is perspective for you as a
> develeper. Originaly I had there a sentence: iBatis will improve more
> dynamically than widely spread standards can ever do (such as JDBC or JPA).
> This sentence was written 2 years ago, but I am not so sure now.
>     When I look into
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/iBATIS+3.0+Whiteboard,
> it has been long since it was seriously touched and I haven't found any
> other clue when or whether there is going to be iBatis 3. There is very
> small activity for 3.x version in Jira, thouhg there are some commits into
> iBatis 3 core (http://www.mail-archive.com/commits <at> ibatis.apache.org/). So
> can anyone give me any answer about iBatis 3, that I can spread further?
> 
> Cheers,
> Jan
> 

Kai Grabfelder | 8 Feb 11:23 2009
Picon

Re: java.sql.SQLException: Already closed.

what do you mean with second request? A request shortly after the first or a request after some minutes?

If the second is the case you could run in the fact that mysql closes connections that are not used for a
while. See e.g.
http://www.nabble.com/java.sql.SQLException:-Already-closed..strange!-td21195800.html

Regards

Kai

--- Original Nachricht ---
Absender: Melvin Wong
Datum: 08.02.2009 02:42
> But now I have a new prob.
> 
>  
> 
> -I'm using iBatis 2.3.4 and DBCP 1.2.2 on Tomcat 6
> 
> -When I start Tomcat and run my first request, things went fine
> 
> -Then I when i run my second request, error below happened
> 
> -My ibatis config file is attached
> 
>  
> 
> **********************************
> 
> ERROR LOG
> 
>  
> 
> java.sql.SQLException: Already closed.
> 
>                 at
> org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:84)
> 
>                 at
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(P
> oolingDataSource.java:181)
> 
>                 at
> com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.close(JdbcTransact
> ion.java:81)
> 
>                 at
> com.ibatis.sqlmap.engine.transaction.TransactionManager.end(TransactionManag
> er.java:93)
> 
>                 at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapEx
> ecutorDelegate.java:734)
> 
>                 at
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSession
> Impl.java:176)
> 
>                 at
> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientIm
> pl.java:153)
> 
>               at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlM
> apExecutorDelegate.java:835)
> 
>                 at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDe
> legate.java:410)
> 
>                 at
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.jav
> a:82)
> 
>                 at
> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:
> 58)
> 
>                 at
> my.com.justmobile.engine.SSUMEngine.log(SSUMEngine.java:408)
> 
>                 at
> my.com.justmobile.engine.SSUMEngine.validate(SSUMEngine.java:292)
> 
>                 at
> my.com.justmobile.engine.SSUMEngine.process(SSUMEngine.java:205)
> 
>                 at
> my.com.justmobile.SSUMServlet.processRequest(SSUMServlet.java:145)
> 
>                 at my.com.justmobile.SSUMServlet.doGet(SSUMServlet.java:242)
> 
>                 at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
> 
>                 at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> 
>                 at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:290)
> 
>                 at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:206)
> 
>                 at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:233)
> 
>                 at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:175)
> 
>                 at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
> )
> 
>                 at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
> )
> 
>                 at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :109)
> 
>                 at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
> 
>                 at
> org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:
> 852)
> 
>                 at
> org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(H
> ttp11AprProtocol.java:584)
> 
>                 at
> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
> 
>                 at java.lang.Thread.run(Thread.java:619)
> 
>  
> 
> Attached are my configurations files. I'm still waiting to discuss your
> rate. I'm open, let me know your thoughts. 
> 
>  
> 
>  
> 
> Thank you for your time to read this email.
> 
> Mel
> 
> 

Ing. Jan Novotný | 8 Feb 11:32 2009
Picon

Re: iBatis 3 roadmap

Yes, I agree with you, that iBatis is already very mature. But on the other hand there is a lot of features mentioned in the iBatis 3 whitepaper, that could increase developer productivity. There is no doubt, that iBatis as it is now, requires a lot of XML, that could be converted to more understable and usable annotations. We have generics for a couple of years and iBatis hasn't had any support yet. I can imagine how big boost to productivity would be to have Interface binding as proposed. These things simply call for new version.

Regards,
Jan

2009/2/8 Kai Grabfelder <nospam <at> kaigrabfelder.de>
This is not really about iBATIS 3 but about the improvements of iBATIS 2. In my opinion it is perfect just the
way it is currently. So iBATIS 2 is not dead or no longer loved by it's devs - it's just very very mature.

Regarding iBATIS 3: I guess Clinton will be able to answer your questions...

Regards

Kai

--- Original Nachricht ---
Absender: Ing. Jan Novotný
Datum: 08.02.2009 10:11
> Hello everybody,
>
>     I'm going to have a speech at czech university about iBatis and among
> the isssues I want to cover is, how the iBatis is perspective for you as a
> develeper. Originaly I had there a sentence: iBatis will improve more
> dynamically than widely spread standards can ever do (such as JDBC or JPA).
> This sentence was written 2 years ago, but I am not so sure now.
>     When I look into
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/iBATIS+3.0+Whiteboard,
> it has been long since it was seriously touched and I haven't found any
> other clue when or whether there is going to be iBatis 3. There is very
> small activity for 3.x version in Jira, thouhg there are some commits into
> iBatis 3 core (http://www.mail-archive.com/commits <at> ibatis.apache.org/). So
> can anyone give me any answer about iBatis 3, that I can spread further?
>
> Cheers,
> Jan
>




--
--------------------------------------------------------------
Ing. Jan Novotný
<at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at> <at>
http://blog.novoj.net
Myšlenky dne otce Fura
--------------------------------------------------------------
Rahul Saluja | 8 Feb 12:05 2009
Picon

Need help on Inserting child Object .

 

Hello Everybody,

 

 I need help to understand how can I insert an object into my Db using which is having an child object.

 

Say I have a class named Order which have an Child Object (an array of type OrderItem ) so how I would write my code in java to associate these two tables

Namely Order

Class Order{

 

public void setOrderItemArray(OrderItem[] newArray);

public OrderItem[] getOrderItemArray();

public void setOrderItem(int index, OrderItem oi);

public OrderItem getOrderItem(int index);

}

 

and OrderItem

 

Class OrderItem{

 

Public void SetOrderItemPrice( int price);

Public int getOrderItemPrice( String OrderItemName );

 

Public void setOrderItemNumber(int OrderItemName);

Public int getOrderItemNumber( String ItemName);

 

 

Public void setOrderItemName(String Name);

Public String getOrderItemName(String Name);

 

}

 

I was Going through book Ibatis in Action and found this example under the topic inserting or updating child object

 

public void saveOrder(SqlMapClient sqlMapClient, Order order)

throws SQLException {

sqlMapClient.startTransaction();

try {

if (null == order.getOrderId()) {

sqlMapClient.insert("Order.insert", order);

} else {

sqlMapClient.update("Order.update", order);

}

sqlMapClient.startBatch();

sqlMapClient.delete("Order.deleteDetails", order);

for (int i=0;i<order.getOrderItems().size();i++) {

OrderItem oi = (OrderItem) order.getOrderItems().get(i);

oi.setOrderId(order.getOrderId());

sqlMapClient.insert("OrderItem.insert", oi);

}

sqlMapClient.executeBatch();

sqlMapClient.commitTransaction();

} finally {

sqlMapClient.endTransaction();

}

}

 

As I was going through above code I have few question why are checking it against null for insert , shouldn’t that be checking for not null

 

Though I can understand that It needs to be done at application level only using sql batch update but an explicit example of the same with corresponding entries in sqlmap would help . If somebody can put some light on this would help me in great manner.

 

Looking forward to your response.

 

Regards

Rahul Saluja

The information contained in this e-mail is private & confidential and may also be legally privileged. If you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or disclose the contents of this message to anyone.

Gmane