ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From I L <iss...@hotmail.com>
Subject RE: Ibatis 3.0 Bugs/Suggestions
Date Mon, 17 Aug 2009 03:09:42 GMT

Thanks Clinton for the quick response!

re ".selectOne is the equivalent of the old queryForObject"... It looks like the new method
throws an exception if a null is returned from the db. The original didn't do that. Its not
a big deal. If I do expect the possibility of a null being returned, I can always just catch
the exception and handle it that way.

re "...hardest methods to name ever"...I know EXACTLY what you mean. Sometimes I spend more
times thinking about what to call a method than coding it!

Cheers!

(P.S., I am now getting the "Not Found" page when trying to download the user guide)
Date: Sun, 16 Aug 2009 11:28:46 -0600
Subject: Re: Ibatis 3.0 Bugs/Suggestions
From: clinton.begin@gmail.com
To: user-java@ibatis.apache.org

Unfortunately this code isn't terribly clear. That was one of the hardest methods to name
ever... :-)

JDBC has to make the call to the resultSet before .wasNull will return an appropriate value.
 

So what "getNullableResult" means is "get me a result from the subclass typehandler, that
might be null, and if it is, take care of it for me with the code below..."


So the way it is, is correct, otherwise rs.wasNull() will return the status of the previous
value.

Clinton

On Sun, Aug 16, 2009 at 10:38 AM, I L <isster@hotmail.com> wrote:






Found a very small performance (milliseconds) change:


In BaseTypeHandler.getResult

Instead of:
    Object result = getNullableResult(rs, columnName);
    if (rs.wasNull()) {
      return null;

    } else {
      return result;
    }

I would put the getNullableResult in the else part of the conditional:
    
    if (rs.wasNull()) {
      return null;
    } else {
      Object result = getNullableResult(rs, columnName);

      return result;
    }


> Date: Sat, 15 Aug 2009 22:24:40 -0600
> Subject: Re: Ibatis 3.0 Bugs/Suggestions
> From: clinton.begin@gmail.com

> To: user-java@ibatis.apache.org
> 
> Excellent feedback. I'll start looking into these tomorrow.  Thanks.

> 
> Clinton
> 
> On Sat, Aug 15, 2009 at 7:31 PM, I L<isster@hotmail.com> wrote:
> > Hi,
> >
> > Awesome product renovation.

> >
> > Heres some things I found that might have already been discussed:
> >
> > 1) http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd

> > Getting error if I try to add either <typeAliases> or <typeAlias> in
a
> > mapper xml file. Works only in a Configuration.xml file.
> >
> > 2) session.select
> > I am able to invoke the three param .select(arg0, arg1, arg2) but not

> > .select(id, param). The id/param select isn't available.
> >
> > There is no examples in the pdf on how to use the three param select.
> >
> > 3) Is there anyway we can keep the colon syntax for defining jdbcType. It

> > could be in addition to the comma seperated diffinations. Just looks cleaner
> > and is much shorter:
> > e.g. #{timeZone,jdbcType=VARCHAR} vs #{timeZone:VARCHAR}
> >
> > e.g.

> >    count != #{usercount,jdbcType=BIGINT} vs count != #{usercount:BIGINT}
> >
> >
> > 4) It would be nice to have a more straight forward way to get access to
> > Connection

> >
> > sqlSession.getConfiguration().getEnvironment().getDataSource().getConnection();
> >        vs
> >        sqlSession.getConnection();
> >
> > 5)
> >     <select id="isUniqueUsername"  parameterType="map"

> > resultType="boolean">
> >         SELECT (count(*) = 0)
> >         FROM user Where 1=0
> >     </select>
> >
> > If I access this select the old fashion way:

> >        ((Boolean) getSession().selectOne("User.isUniqueUsername",
> > map)).booleanValue();
> >
> > ... I get a "Casting Exception". Apparently a Long is returned instead of a

> > Boolean. I am running on a mysql database. As you know, mysql deals with
> > booleans as bits (1's or 0's). Oddly enough this works fine in the ibatis
> > 2.x versions.
> >

> > 6) Not sure if this will be of any use to anyone, but I've written a
> > CalendarTypeHandler. On the surface, it seems to be working fine
> >
> >
> > public class CalendarTypeHandler extends BaseTypeHandler {

> >
> >     public void setNonNullParameter(PreparedStatement ps, int i, Object
> > parameter, JdbcType jdbcType) throws SQLException {
> >         Calendar calendar = (Calendar) parameter;

> >         ps.setTimestamp(i, (new Timestamp(calendar.getTimeInMillis())));
> >     }
> >
> >     public Object getNullableResult(ResultSet rs, String columnName) throws
> > SQLException {

> >         java.sql.Timestamp sqlTimestamp = rs.getTimestamp(columnName);
> >         if (sqlTimestamp != null) {
> >             return new java.util.Date(sqlTimestamp.getTime());
> >         }

> >         return null;
> >     }
> >
> >     public Object getNullableResult(CallableStatement cs, int columnIndex)
> > throws SQLException {
> >         java.sql.Timestamp sqlTimestamp = cs.getTimestamp(columnIndex);

> >         if (sqlTimestamp != null) {
> >             return new java.util.Date(sqlTimestamp.getTime());
> >         }
> >         return null;
> >     }
> >
> > }

> >
> > 7) Picky user guide stuff
> > The User guide is overall very clean, complete, and clear. Great job!!!
> >
> > a)"....There are two TransactionManager types (i.e. type=”?????”) that are in...".

> > What is the ???? suppose to be?
> > b) An explanation about the Enum type handler would be nice (like what's
> > persisted, code or index. Is it configurable?)
> > c)
> > "The iBATIS XML configuration file is contains settings and properties that have
a dramatic effect on how..."

> > Get rid of "is"
> >
> > 8) What .selectOne() is isn't clear. Maybe a note that an exception will be
> > thrown if either a list or a null is returned?
> >
> >

> > Thats all I have found so far. Cheers!
> >
> >
> > ________________________________
> > Windows Live™: Keep your life in sync. Check it out.
> 

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org

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

Windows Live: Keep your friends up to date with what you do online. Find out more.



_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009
Mime
View raw message