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 a b <eo...@yahoo.com> on 2009/11/04 18:45:45 UTC
ibatis 3 petstore
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
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
>
>