For point 5, it seems type handlers are ignored when simple types are set as resultType.
I have a select. <select id="selectHasRole" resultType="java.lang.Boolean" parameterType="ca.qc.ircm.lims.persistence.mapper.AuthenticatingMapper$RoleTest"> The log does not show my boolean type handler... 2009-09-21 10:55:29,579 - DEBUG - debug - <== Columns: [COUNT(*)] - org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl - (christian.poit...@ircm.qc.ca) - 26 2009-09-21 10:55:29,579 - DEBUG - debug - <== Row: [0] - org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl - (christian.poit...@ircm.qc.ca) - 26 2009-09-21 10:55:29,595 - ERROR - logger - java.lang.Long - ca.qc.ircm.lims.web.handler.ExceptionHandler - (christian.poit...@ircm.qc.ca) - 36 java.lang.ClassCastException: java.lang.Long at $Proxy82.selectHasRole(Unknown Source) at ca.qc.ircm.lims.service.AuthenticatingServiceDefault.hasRole(AuthenticatingServiceDefault.java:63) Curiously enough, the type handler is used when it's a property of a complex object. I'll create a JIRA for this. Christian ________________________________ From: Clinton Begin [mailto:clinton.be...@gmail.com] Sent: Sunday, August 16, 2009 1:13 PM To: user-java@ibatis.apache.org Subject: Re: Ibatis 3.0 Bugs/Suggestions I've made it through these items... don't take offence to the strikethroughs, I used your list as a sort of TODO list. :-) Your comments were very helpful, and offered a different perspective for both the software and the documentation. It's always amazing how one person might thing something is self explanatory and clear as day, and another sees something completely different. :-) I've implemented the doc advice, and addressed some of the other points below. Cheers, Clinton 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. This is intentional. TypeAliases are all defined in the config now. The old way left it ambiguous as to which type was being referenced, and it became more complicated with cross-mapping references to ResultMaps or statements in other mapping files. 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. This is a documentation problem if it's not clear. I'll see what I can do to clear it up. In a nutshell: .selectOne is the equivalent of the old queryForObject -- use it when selecting one instance of your result object. .selectList is the equivalent of the old queryForList -- use it when selecting a list of your result objects. .select is used when you want to control how your results are loaded with the ResultHandler. And I think you're right, I don't believe I documented the ResultHandler impl. 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} Certainly there's a way. :-) You make a good argument, and I think we can support it. I'll try to get it in for the next Beta. 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(); I'll think about that one. My gut tells me we probably won't support that. While it would save some typing, we want to discourage it. The challenge is that sometimes iBATIS can be configured without a datasource (although we also want to discourage that if you want to use lazy loading). Maybe this is something best left to a quick little utility method. 5) ... 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. iBATIS 3 is more strict in the typing. JDBC has a get/setBoolean method pair, so be sure to define your result type as boolean, then this should work. Otherwise you're literally trying to cast an integer to a boolean. Note that this relies on the driver's support for translating the 1/0 during the call to get/setBoolean. Otherwise you'll need to create a DB specific type handler. 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 I'll create a section on the wiki for contributed type handlers.... once our wiki is back up! Ticket submitted to atlassian... 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" All addressed... thanks for keeping these notes. 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? I added a bit to the doc to hopefully clear this up. On Sat, Aug 15, 2009 at 7:31 PM, I L<iss...@hotmail.com<mailto:iss...@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(tm): Keep your life in sync. Check it out.