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 Mahesh219 <ma...@gmail.com> on 2009/11/02 06:07:59 UTC

iBatis API for fetching the sqlmap queries

Hi,
We are using iBatis 3 with Spring.

We wish to provide our DAOs with both,  Spring's JdbcTemplate and iBatis
SqlMapClientTemplate facilities.

Does iBatis provide a way to fetch the queries defined in one of the xmls
using the id attribute programmatically?

Any help is highly appreciated.

Regards,
Mahesh
-- 
View this message in context: http://old.nabble.com/iBatis-API-for-fetching-the-sqlmap-queries-tp26156026p26156026.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

Re: iBatis API for fetching the sqlmap queries

Posted by Clinton Begin <cl...@gmail.com>.
Yes, you can introspect on the full iBATIS configuration at runtime by
grabbing the Configuration instance from the SqlSessionFactory.  It has
lists and maps of various configuration components.

Clinton

On Sun, Nov 1, 2009 at 10:07 PM, Mahesh219 <ma...@gmail.com> wrote:

> Hi, We are using iBatis 3 with Spring. We wish to provide our DAOs with
> both, Spring's JdbcTemplate and iBatis SqlMapClientTemplate facilities. Does
> iBatis provide a way to fetch the queries defined in one of the xmls using
> the id attribute programmatically? Any help is highly appreciated. Regards,
> Mahesh
> ------------------------------
> View this message in context: iBatis API for fetching the sqlmap queries<http://old.nabble.com/iBatis-API-for-fetching-the-sqlmap-queries-tp26156026p26156026.html>
> Sent from the iBATIS - User - Java mailing list archive<http://old.nabble.com/iBATIS---User---Java-f370.html>at Nabble.com.
>

Re: ibatis 3 COUNT -> Boolean

Posted by Johannes Klose <li...@calitrix.de>.
You could just modify the query to return a boolean value to avoid  
conversion issues. For example:
	SELECT IF(COUNT(username)>0,true,false) FROM record WHERE ...


Am 04.11.2009, 19:42 Uhr, schrieb Douglas Bell <DB...@boingo.com>:

> I'm trying to do the following using beta 5 (this was working in beta 3)
>
> @Select("SELECT COUNT(username) FROM record WHERE username =
> #{username,jdbcType=VARCHAR}")
> Boolean isExisting(String username);
>
> I get a ClassCastException: java.lang.Long cannot be cast to
> java.lang.Boolean which is understandable.
>
> I thought adding a @Result(javaType = Boolean.class) would do it but I
> still get the same error. Can I do anything short of changing the return
> type to a Long and doing the conversion?
>
> Thanks
>
> -Doug
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: ibatis 3 COUNT -> Boolean

Posted by Nathan Maves <na...@gmail.com>.
here is the java doc for how the resultset implementation should handle
this.  As long as your query will only return 0/1 you should be okay.  If
not, then I would just wrap the count() in an if and return a 1 if count was
more than 1.

I would also set both the jdbc type and the return type.  jdbcType to NUMBER
and Boolean for the Result.

Nathan


getBoolean

boolean *getBoolean*(int columnIndex)
                   throws SQLException
<http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html>

Retrieves the value of the designated column in the current row of this
ResultSet object as a boolean in the Java programming language.

If the designated column has a datatype of CHAR or VARCHAR and contains a
"0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and
contains a 0, a value of false is returned. If the designated column has a
datatype of CHAR or VARCHAR and contains a "1" or has a datatype of BIT,
TINYINT, SMALLINT, INTEGER or BIGINT and contains a 1, a value of true is
returned.



On Wed, Nov 4, 2009 at 12:42 PM, Douglas Bell <DB...@boingo.com> wrote:

> I'm trying to do the following using beta 5 (this was working in beta 3)
>
> @Select("SELECT COUNT(username) FROM record WHERE username =
> #{username,jdbcType=VARCHAR}")
> Boolean isExisting(String username);
>
> I get a ClassCastException: java.lang.Long cannot be cast to
> java.lang.Boolean which is understandable.
>
> I thought adding a @Result(javaType = Boolean.class) would do it but I
> still get the same error. Can I do anything short of changing the return
> type to a Long and doing the conversion?
>
> Thanks
>
> -Doug
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

ibatis 3 COUNT -> Boolean

Posted by Douglas Bell <DB...@boingo.com>.
I'm trying to do the following using beta 5 (this was working in beta 3)

@Select("SELECT COUNT(username) FROM record WHERE username =
#{username,jdbcType=VARCHAR}")
Boolean isExisting(String username);

I get a ClassCastException: java.lang.Long cannot be cast to
java.lang.Boolean which is understandable. 

I thought adding a @Result(javaType = Boolean.class) would do it but I
still get the same error. Can I do anything short of changing the return
type to a Long and doing the conversion?

Thanks 

-Doug

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: ibatis 3 petstore

Posted by Nathan Maves <na...@gmail.com>.
I started on one but got pulled away with real life :)  Guess I need a
vacation to get some free time to code :)  Man that sounds like hell.

On Wed, Nov 4, 2009 at 11:45 AM, a b <eo...@yahoo.com> wrote:

> Is there a sample application written in ibatis 3 and spring such as
> petstore?
>
> thanks
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

ibatis 3 petstore

Posted by a b <eo...@yahoo.com>.
Is there a sample application written in ibatis 3 and spring such as petstore?

thanks


      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org