Christopher.Mathrusse | 11 Oct 00:33 2006
Picon

Enum typeHandlerCallback

I'm attempting to implement a TypeHandlerCallback to handle an Enum. The Enum is declared within a class but I can't seem to figure out how to do this correctly. I keep getting an exception thrown at startup because iBatis cannot seem to load the enum. In the Resources class, the method classForName(String) keeps throwing an exception based upon the javaType that I have specified in my config file.
 
SqlMapConfig Type Handler declaration:

<typeHandler javaType="com.sybase.cosmos.domain.DocumentStore.State" callback="com.sybase.cosmos.dao.impl.ibatis.extentions.DocStoreStateTypeHandlerCallback" />

Enum defined in java class:

public

class DocumentStore extends DomainObject {

public static enum State { INITIALIZED, PROCESSING, COMPLETE, ERROR }

The following in Resources.classForName(String), which is using the class loader, cannot locate the enum that I have specified.  So how can I tell iBatis to use my TypeHandlerCallback for this enum?

 

Thanks....

 
Chris Mathrusse
(925) 236-5553
 
Niels Beekman | 11 Oct 00:51 2006
Picon

RE: Enum typeHandlerCallback

You can’t start an enum using Class.forName(), so iBATIS can’t either. Afaik you can only use the typehandler by specifying it explictily inside a (inline) parameterMap or resultMap.

 

Niels

 

From: Christopher.Mathrusse <at> sybase.com [mailto:Christopher.Mathrusse <at> sybase.com]
Sent: woensdag 11 oktober 2006 0:33
To: user-java <at> ibatis.apache.org
Subject: Enum typeHandlerCallback

 

I'm attempting to implement a TypeHandlerCallback to handle an Enum. The Enum is declared within a class but I can't seem to figure out how to do this correctly. I keep getting an exception thrown at startup because iBatis cannot seem to load the enum. In the Resources class, the method classForName(String) keeps throwing an exception based upon the javaType that I have specified in my config file.

 

SqlMapConfig Type Handler declaration:

<typeHandler javaType="com.sybase.cosmos.domain.DocumentStore.State" callback="com.sybase.cosmos.dao.impl.ibatis.extentions.DocStoreStateTypeHandlerCallback" />

Enum defined in java class:

public class DocumentStore extends DomainObject {

public static enum State { INITIALIZED, PROCESSING, COMPLETE, ERROR }

The following in Resources.classForName(String), which is using the class loader, cannot locate the enum that I have specified.  So how can I tell iBatis to use my TypeHandlerCallback for this enum?

 

Thanks....

 

Chris Mathrusse

christopher.mathrusse <at> sybase.com

(925) 236-5553

 

Larry Meadors | 11 Oct 00:57 2006
Picon

Re: Enum typeHandlerCallback

An inner enum class?

Hmm, should it be:

javaType="com.sybase.cosmos.domain.DocumentStore$State"

Larry

On 10/10/06, Christopher.Mathrusse <at> sybase.com
<Christopher.Mathrusse <at> sybase.com> wrote:
>
>
> I'm attempting to implement a TypeHandlerCallback to handle an Enum. The
> Enum is declared within a class but I can't seem to figure out how to do
> this correctly. I keep getting an exception thrown at startup because iBatis
> cannot seem to load the enum. In the Resources class, the method
> classForName(String) keeps throwing an exception based upon the javaType
> that I have specified in my config file.
>
> SqlMapConfig Type Handler declaration:
>
>
> <typeHandler
> javaType="com.sybase.cosmos.domain.DocumentStore.State"
> callback="com.sybase.cosmos.dao.impl.ibatis.extentions.DocStoreStateTypeHandlerCallback"
> />
>
> Enum defined in java class:
>
>
> public class DocumentStore extends DomainObject {
>
> public static enum State { INITIALIZED, PROCESSING, COMPLETE, ERROR }
>
>
> The following in Resources.classForName(String), which is using the class
> loader, cannot locate the enum that I have specified.  So how can I tell
> iBatis to use my TypeHandlerCallback for this enum?
>
>
>
> Thanks....
>
> Chris Mathrusse
> christopher.mathrusse <at> sybase.com
> (925) 236-5553
>

Niels Beekman | 11 Oct 00:59 2006
Picon

RE: Enum typeHandlerCallback

Hmm, I should probably get some sleep :)
Tested it, works perfectly well...

Thanks Larry!

-----Original Message-----
From: larry.meadors <at> gmail.com [mailto:larry.meadors <at> gmail.com] On Behalf
Of Larry Meadors
Sent: woensdag 11 oktober 2006 0:57
To: user-java <at> ibatis.apache.org
Subject: Re: Enum typeHandlerCallback

An inner enum class?

Hmm, should it be:

javaType="com.sybase.cosmos.domain.DocumentStore$State"

Larry

On 10/10/06, Christopher.Mathrusse <at> sybase.com
<Christopher.Mathrusse <at> sybase.com> wrote:
>
>
> I'm attempting to implement a TypeHandlerCallback to handle an Enum.
The
> Enum is declared within a class but I can't seem to figure out how to
do
> this correctly. I keep getting an exception thrown at startup because
iBatis
> cannot seem to load the enum. In the Resources class, the method
> classForName(String) keeps throwing an exception based upon the
javaType
> that I have specified in my config file.
>
> SqlMapConfig Type Handler declaration:
>
>
> <typeHandler
> javaType="com.sybase.cosmos.domain.DocumentStore.State"
>
callback="com.sybase.cosmos.dao.impl.ibatis.extentions.DocStoreStateType
HandlerCallback"
> />
>
> Enum defined in java class:
>
>
> public class DocumentStore extends DomainObject {
>
> public static enum State { INITIALIZED, PROCESSING, COMPLETE, ERROR }
>
>
> The following in Resources.classForName(String), which is using the
class
> loader, cannot locate the enum that I have specified.  So how can I
tell
> iBatis to use my TypeHandlerCallback for this enum?
>
>
>
> Thanks....
>
> Chris Mathrusse
> christopher.mathrusse <at> sybase.com
> (925) 236-5553
>

Christopher.Mathrusse | 11 Oct 01:01 2006
Picon

RE: Enum typeHandlerCallback

Sweet!!! That did the trick.
 
Thanks very much Larry!

From: larry.meadors <at> gmail.com [mailto:larry.meadors <at> gmail.com] On Behalf Of "Larry Meadors" <lmeadors <at> apache.org>
Sent: Tuesday, October 10, 2006 3:57 PM
To: user-java <at> ibatis.apache.org
Subject: Re: Enum typeHandlerCallback

An inner enum class?

Hmm, should it be:

javaType="com.sybase.cosmos.domain.DocumentStore$State"

Larry


On 10/10/06, Christopher.Mathrusse <at> sybase.com
wrote:
>
>
> I'm attempting to implement a TypeHandlerCallback to handle an Enum. The
> Enum is declared within a class but I can't seem to figure out how to do
> this correctly. I keep getting an exception thrown at startup because iBatis
> cannot seem to load the enum. In the Resources class, the method
> classForName(String) keeps throwing an exception based upon the javaType
> that I have specified in my config file.
>
> SqlMapConfig Type Handler declaration:
>
>
> > javaType="com.sybase.cosmos.domain.DocumentStore.State"
> callback="com.sybase.cosmos.dao.impl.ibatis.extentions.DocStoreStateTypeHandlerCallback"
> />
>
> Enum defined in java class:
>
>
> public class DocumentStore extends DomainObject {
>
> public static enum State { INITIALIZED, PROCESSING, COMPLETE, ERROR }
>
>
> The following in Resources.classForName(String), which is using the class
> loader, cannot locate the enum that I have specified. So how can I tell
> iBatis to use my TypeHandlerCallback for this enum?
>
>
>
> Thanks....
>
> Chris Mathrusse
> christopher.mathrusse <at> sybase.com
> (925) 236-5553
>

Clinton Begin | 11 Oct 04:56 2006
Picon

Re: duplicate column names

No. 

This would be a impossible solution.  We can't arbitrairly map two columns with the same name, unless you wanted to do it by column number.  But that is also arbitrary with SELECT *.

I'm afraid you're asking for the impossible.  I suggest you use aliases.

Clinton

On 10/10/06, Maarten Bosteels <mbosteels.dns <at> gmail.com> wrote:
Hello,

I found this example in the Developer Guide::

<resultMap id="get-product-result" class="com.ibatis.example.Product">
<result property="id" column="PRD_ID"/>
<result property="description" column="PRD_DESCRIPTION"/>
<result property="category" resultMap="get-category-result" />
</resultMap>

<resultMap id="get-category-result" class=" com.ibatis.example.Category">
<result property="id" column="CAT_ID" />
<result property="description" column="CAT_DESCRIPTION" />
</resultMap>

<select id="getProduct" parameterClass="int" resultMap="get-product-result">
select *
from PRODUCT, CATEGORY
where PRD_CAT_ID=CAT_ID
and PRD_ID = #value#
</select>

What if the columns in PRODUCT and CATEGORY do not have the PRD_ and CAT_
prefixes and share column-names (eg ID) ?
It would most probably work to have a column alias for every column
but I would like to avoid that and stick with the star in "select *
from"

I am having a similar problem with RowMapper and Spring's JDBCTemplate
and wondered if iBatis has a solution.

Thanks, I hope my question is clear.

Maarten

Maarten Bosteels | 11 Oct 09:35 2006
Picon

Re: duplicate column names

I was afraid you were gonna say that :-)
It's too bad that this query

  select PRODUCT.*, CATEGORY.* from PRODUCT, CATEGORY where ...

does not yield column-names like
"PRODUCT.ID", "PRODUCT.DESCRIPTION", "CATEGORY.ID", ...

That's of course a short-coming of jdbc (or rather of SQL itself), not iBatis.

Maarten

On 10/11/06, Clinton Begin <clinton.begin <at> gmail.com> wrote:
> No.
>
> This would be a impossible solution.  We can't arbitrairly map two columns
> with the same name, unless you wanted to do it by column number.  But that
> is also arbitrary with SELECT *.
>
> I'm afraid you're asking for the impossible.  I suggest you use aliases.
>
> Clinton
>
>
> On 10/10/06, Maarten Bosteels <mbosteels.dns <at> gmail.com> wrote:
> > Hello,
> >
> > I found this example in the Developer Guide::
> >
> > <resultMap id="get-product-result" class="com.ibatis.example.Product">
> > <result property="id" column="PRD_ID"/>
> > <result property="description" column="PRD_DESCRIPTION"/>
> > <result property="category" resultMap="get-category-result" />
> > </resultMap>
> >
> > <resultMap id="get-category-result" class=" com.ibatis.example.Category">
> > <result property="id" column="CAT_ID" />
> > <result property="description" column="CAT_DESCRIPTION" />
> > </resultMap>
> >
> > <select id="getProduct" parameterClass="int"
> resultMap="get-product-result">
> > select *
> > from PRODUCT, CATEGORY
> > where PRD_CAT_ID=CAT_ID
> > and PRD_ID = #value#
> > </select>
> >
> > What if the columns in PRODUCT and CATEGORY do not have the PRD_ and CAT_
> > prefixes and share column-names (eg ID) ?
> > It would most probably work to have a column alias for every column
> > but I would like to avoid that and stick with the star in "select *
> > from"
> >
> > I am having a similar problem with RowMapper and Spring's JDBCTemplate
> > and wondered if iBatis has a solution.
> >
> > Thanks, I hope my question is clear.
> >
> > Maarten
> >
>
>

trevor paterson (RI | 11 Oct 11:09 2006
Picon
Picon

RE: closing connections

cheers

restarting tomcat seems to be the easiest fix to releasing the
connections to the database

(or going in and kkilling them manually) 

Trevor Paterson

Bioinformatics
Roslin Institute
Scotland EH25 9PS
phone  +44 (0) 131 5274477
http://www.roslin.ac.uk/
http://www.comparagrid.org/

The information contained in this e-mail (including any attachments) is
confidential and is intended for the use of the addressee only.   The
opinions expressed within this e-mail (including any attachments) are
the opinions of the sender and do not necessarily constitute those of
Roslin Institute (Edinburgh) ("the Institute") unless specifically
stated by a sender who is duly authorised to do so on behalf of the
Institute.

-----Original Message-----
From: Graeme J Sweeney [mailto:ibatis.user <at> gjsweeney.com] 
Sent: 10 October 2006 17:17
To: iBatis List
Subject: Re: closing connections

On Tue, 10 Oct 2006, trevor paterson (RI) wrote:

> we are developing a webapp on netbeans/tomcat and using ibatis to 
> connect to a remote postgres database
>
> during development we are deploying the web app through netbeans - and

> when we stop the webapp we seem to leave dangling connections which 
> then accumaulate in the database server..causing us problems.
>
> is their some way to grab Ibatis's connection pool and close all the 
> connections prior to us stoping the webapp?

This thread might help:

http://marc2.theaimsgroup.com/?l=tomcat-user&m=113078045432700&w=2

--
Graeme -

sonusgr | 11 Oct 14:43 2006
Picon

Re: Invalid Number


Thanks for your quick reply. I tried setting the string as
searchVO.setCostComponentIdArrayAsString("\"1234\",\"456\",\"588\"");
so that it would get into the sqlmap as  "1234","456","588"
but no luck. Still getting invalid number.
I also tried hard coding them inside the sqlmap with quotes but still no
luck.
Did I misunderstood something?

Thanks

Larry Meadors-2 wrote:
> 
> iBATIS uses prepared statements for this, so the SQL that is being
> executed is like this:
> 
> ... AND COMPONENT_MOVEMENT_TYPE_ID in ("12,34,56")
> 
> That won't work. you need to make the values like this:
> 
> ... AND COMPONENT_MOVEMENT_TYPE_ID in ("12","34","56")
> 
> That means you either use sql injection (err, substitution I mean) like
> this:
> 
> ... AND COMPONENT_MOVEMENT_TYPE_ID in ($someValues$)
> 
> ...or you need to pass in an array or list and search the archives for
> "dynamic sql" and "iterate". I'd highly reccomend this approach over
> the $other$.
> 
> Larry
> 
> 
> On 10/10/06, sonusgr <sonusgr <at> gmail.com> wrote:
>>
>> Hi guys,
>>
>> I am trying to pass a string of numbers to the my sql statement
>> but  I am getting SQLException invalid number
>>
>> The funny thing is that this occurs only when I am passing more than one
>> number, meaning if that string I am passing
>> having more than one number.
>>
>> so in DAO we ve got :
>> searchVO.setCostComponentIdArrayAsString("1234,456,588");
>>                         flights =
>> this.sqlMap.queryForList("getFlightsbyCriteria", searchVO);
>>
>>
>> and in sqlMap:
>> AND COMPONENT_MOVEMENT_TYPE_ID in (#costComponentIdArrayAsString#)
>>
>> that throws the SQLException
>>
>> ---------
>>
>> But if I do searchVO.setCostComponentIdArrayAsString("1234");
>> works fine...
>>
>> What am I doing wrong here?
>> could it be a backend error?
>>
>> thanks guys
>> --
>> View this message in context:
>> http://www.nabble.com/Invalid-Number-tf2417727.html#a6739736
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

--

-- 
View this message in context: http://www.nabble.com/Invalid-Number-tf2417727.html#a6755642
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

C.Zecca | 11 Oct 16:21 2006
Picon

Re: Stored procedures (package functions) returning a row

Jeff

Your XML config code exerted by the following Java code

SqlMapClient lSqlMapClient = Configurazione.getSqlMapIstanza();

    ChiaveBean lChiaveBean = new ChiaveBean();
       try
       {
        lSqlMapClient.update( "row_return_parMap", lChiaveBean );
       }
...

does not work. Here is the diagnostic

    DEBUG [main] - {pstm-100001} PreparedStatement: { ? = call ut_Foo.get_key_2 }
    DEBUG [main] - {pstm-100001} Parameters: []
    DEBUG [main] - {pstm-100001} Types: []
    com.ibatis.common.jdbc.exception.NestedSQLException:  
    --- The error occurred in it/finmatica/gpj/aa/frontebd/RowReturnTest.xml.  
    --- The error occurred while applying a parameter map.  
    --- Check the GPJ.parMap.  
    --- Check the statement (update procedure failed).  
    --- Cause: java.sql.SQLException: ORA-06550: line 1, column 20:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

We give up.
:/

After, all, if Oracle does not support any JDBC driver able to return complex types (records, tables, ...) how could iBatis?
The team is going to overload some functions and procedure in the PL/SQL packages to add their versions whose signatures will be based only on basic SQL types.

"Jeff Butler" <jeffgbutler <at> gmail.com>


          "Jeff Butler" <jeffgbutler <at> gmail.com>

          10/10/2006 16:32

          Per favore, rispondere a
          user-java <at> ibatis.apache.org

Per

user-java <at> ibatis.apache.org

CC


Oggetto

Re: Stored procedures (package functions) returning a row

Try this:

<parameterMap id="parmMap" class="it.finmatica.gpj.aa.frontebd.ChiaveBean">
<parameter property="id" jdbcType="INTEGER" javaType="int" mode="OUT"/>
</parameterMap>

<procedure id="get_key_2" parameterMap="parmMap">
{ ? = call ut_Foo.get_key_2 }
</procedure>

Everything else the same.

Jeff Butler




On 10/10/06, C.Zecca <at> ads.it <C.Zecca <at> ads.it> wrote:

      C.Zecca <at> ads.it scritti il 06/10/2006 14:57:31

      > It is not feasible for Oracle JDBC drivers to support calling
      > arguments or return values of the PL/SQL types TABLE (now known as
      > indexed-by tables), RESULT SET, RECORD, or BOOLEAN
      > http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#34_05


      I followed the Jeff's suggestion to use update then call it with syntax is like {? = call myFunction}.

      XML file config
          <?xml version="1.0" encoding="UTF-8" ?>

          <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" 
             "http://ibatis.apache.org/dtd/sql-map-2.dtd"> 

          <sqlMap namespace="GPJ">

          <resultMap id="resMap" class="it.finmatica.gpj.aa.frontebd.ChiaveBean ">
          <result property="id" column="tipo_dato_ID" jdbcType="INTEGER" javaType="int"/>
          </resultMap>

          <procedure id="get_key_2" resultMap="resMap">
          { ? = call ut_Foo.get_key_2 }
          </procedure>

          </sqlMap>

      Java

             SqlMapClient lSqlMapClient = Configurazione.getSqlMapIstanza();

             ChiaveBean lChiaveBean = new ChiaveBean();
             try
             {
             lSqlMapClient.update( "get_key_2", lChiaveBean );
             }
             catch (SQLException pException)
             {
             pException.printStackTrace ();
             throw pException;
             }
             int lInt = lChiaveBean.getId();

      ChiaveBean is a simple JavaBean class with a single property of int type anmed id and its setter/getter methods


      PL/SQL
          create or replace package ut_foo is

          type t_PK is record
          ( tipo_dato_ID number( 10)
          );

          function get_key_2
          return t_PK;
          pragma restrict_references( get_key_2, WNDS );

          [...]

      generated SQL

      [*] DEBUG [main] - {pstm-100001} PreparedStatement: { ? = call ut_Foo.get_key_2 }

      Raises the following exception
          com.ibatis.common.jdbc.exception.NestedSQLException:  
          --- The error occurred in it/finmatica/gpj/aa/frontebd/FooTest.xml.  
          --- The error occurred while applying a parameter map.  
          --- Check the get_key_2-InlineParameterMap.  
          --- Check the statement (update procedure failed).  
          --- Cause: java.sql.SQLException: ORA-01008: not all variables bound

          Caused by: java.sql.SQLException: ORA-01008: not all variables bound

          at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
          at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:500 )
          at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:85 )
      [...]


      What's wrong? Any suggestion?
      There are around a number of references to the ORA-1008 error and it seems a quite irksome error.

      For the second question (about learning iBatis) I will open a new thread

      Regards


Gmane