|
Please let me know if I can provide additional details. Thanks for
your help :) On Aug 26, 10:36 am, Jim <[hidden email]> wrote: > Below is the log from calling the getUserByUserName method (as you can > see - the getUserRolesByUserName is not called). > > 2010-08-26 10:30:54,157 DEBUG [main] org.apache.ibatis.io.ResolverUtil > - Reader entry: BooleanToYorN.class - 1613 > 2010-08-26 10:30:54,167 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Reader entry: YorNToBoolean.class > - 1623 > 2010-08-26 10:30:54,167 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Found class file: com/myplace/orm/ > mybatis/typehandlers/BooleanToYorN.class - 1623 > 2010-08-26 10:30:54,167 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Found class file: com/myplace/orm/ > mybatis/typehandlers/YorNToBoolean.class - 1623 > 2010-08-26 10:30:54,167 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Checking to see if class > com.myplace.orm.mybatis.typehandlers.BooleanToYorN matches criteria > [is assignable to TypeHandler] - 1623 > 2010-08-26 10:30:54,167 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Checking to see if class > com.myplace.orm.mybatis.typehandlers.YorNToBoolean matches criteria > [is assignable to TypeHandler] - 1623 > 2010-08-26 10:30:54,207 DEBUG [main] java.sql.Connection - ooo > Connection Opened - 1663 > 2010-08-26 10:30:54,397 DEBUG [main] java.sql.PreparedStatement - > ==> Executing: select username, password, isenabled, > isaccountnonexpired, isaccountnonlocked, iscredentialsnonexpired, > first_name, last_name, address_line_1, address_line_2, city_name, > state, zip_code5 from users join persons on (username = person_id) > left outer join addresses a on (username = a.person_id and > a.address_type_code = 'A') where username = ? - 1853 > 2010-08-26 10:30:54,457 DEBUG [main] java.sql.PreparedStatement - ==> > Parameters: [hidden email](String) - 1913 > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > Columns: USERNAME, PASSWORD, ISENABLED, ISACCOUNTNONEXPIRED, > ISACCOUNTNONLOCKED, ISCREDENTIALSNONEXPIRED, FIRST_NAME, LAST_NAME, > ADDRESS_LINE_1, ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - 1953 > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > Row: [hidden email], xxxxxxx, Y, Y, Y, Y, Bozo, TheClown, 23rd > W. Park, Cubicle C, Boston, MA, 02114 - 1953 > 2010-08-26 10:30:54,517 DEBUG [main] java.sql.Connection - xxx > Connection Closed - 1973 > > On Aug 26, 7:29 am, Clinton Begin <[hidden email]> wrote: > > > > > What if you enable logging... can you see the statement being executed? > > Breakpoint in the constructor doesn't tell us much about what's going on in > > MyBatis. > > > On Wed, Aug 25, 2010 at 10:03 PM, Jim <[hidden email]> wrote: > > > No. I place a breakpoint in the Role constructor class then call the > > > getUserByUserName method but it never breaks and the rolesAdopted > > > property in the AuthorizedUser object is null. But if I invoke the > > > getUserRolesByUserName method independently - it works fine. Thanks > > > for you help. > > > > On Aug 25, 8:59 pm, Clinton Begin <[hidden email]> wrote: > > > > Can you tell if it's being called at all? > > > > > On Wed, Aug 25, 2010 at 7:35 PM, Jim <[hidden email]> wrote: > > > > > I have the following simple example that should be working > > > > > (independently they do) but the "many=@Many" result for the > > > > > rolesAdopted property (that should be calling the "getUserRolesByName" > > > > > and executing the constructor for instantiating an immutable type) > > > > > does not work. Any idea would be appreciated: > > > > > > @Select("select username, password, isenabled," + > > > > > " isaccountnonexpired, isaccountnonlocked, > > > > > iscredentialsnonexpired, " + > > > > > " first_name, last_name, " + > > > > > " address_line_1, address_line_2, " + > > > > > " city_name, state, zip_code5" + > > > > > " from users join persons on (username = person_id) " + > > > > > " left outer join addresses a on (username = a.person_id > > > > > and a.address_type_code = 'A') " + > > > > > " where username = #{userName}") > > > > > @Results(value = { > > > > > @Result(property="firstName", > > > > > column="first_name"), > > > > > @Result(property="lastName", > > > > > column="last_name"), > > > > > @Result(property="addressLine1", > > > > > column="address_line_1"), > > > > > @Result(property="addressLine2", > > > > > column="address_line_2"), > > > > > @Result(property="city", column="city_name"), > > > > > @Result(property="zipCode", column="zip_code5"), > > > > > @Result(property="rolesAdopted", > > > > > javaType=List.class, many=@Many(select="getUserRolesByUserName"))}) > > > > > List<AuthorizedUser> getUserByUserName(String userName); > > > > > > @Select("select username, authority, isenabled from authorities > > > > > where username = #{userName}") > > > > > @ConstructorArgs(value = { > > > > > @Arg(column="username",javaType=String.class), > > > > > @Arg(column="authority",javaType=String.class), > > > > > @Arg(column="isenabled", javaType=Boolean.class, > > > > > typeHandler=com.myplace.orm.mybatis.typehandlers.BooleanToYorN.class) > > > > > }) > > > > > List<Role> getUserRolesByUserName(String userName);- Hide quoted > > > text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - |
|
Administrator
|
Since nobody is responding with a similar experience, the best thing to do to speed up investigation on our end is for you to write an isolated unit test against HSQLDB or Derby. Two databases are provided with the MyBatis source code, so you don't have to create your own. Check out the source and look for the "submitted" directory to see what others have done.
Cheers, Clinton
On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]> wrote: Please let me know if I can provide additional details. Thanks for |
|
My unit tests are written against HSQLDB where would I submit the
samples? Is there an email address or do I just attach it to this thread? Thanks. On Aug 29, 6:27 pm, Clinton Begin <[hidden email]> wrote: > Since nobody is responding with a similar experience, the best thing to do > to speed up investigation on our end is for you to write an isolated unit > test against HSQLDB or Derby. Two databases are provided with the MyBatis > source code, so you don't have to create your own. Check out the source and > look for the "submitted" directory to see what others have done. > > Cheers, > Clinton > > > > On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]> wrote: > > Please let me know if I can provide additional details. Thanks for > > your help :) > > > On Aug 26, 10:36 am, Jim <[hidden email]> wrote: > > > Below is the log from calling the getUserByUserName method (as you can > > > see - the getUserRolesByUserName is not called). > > > > 2010-08-26 10:30:54,157 DEBUG [main] org.apache.ibatis.io.ResolverUtil > > > - Reader entry: BooleanToYorN.class - 1613 > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > org.apache.ibatis.io.ResolverUtil - Reader entry: YorNToBoolean.class > > > - 1623 > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > org.apache.ibatis.io.ResolverUtil - Found class file: com/myplace/orm/ > > > mybatis/typehandlers/BooleanToYorN.class - 1623 > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > org.apache.ibatis.io.ResolverUtil - Found class file: com/myplace/orm/ > > > mybatis/typehandlers/YorNToBoolean.class - 1623 > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > com.myplace.orm.mybatis.typehandlers.BooleanToYorN matches criteria > > > [is assignable to TypeHandler] - 1623 > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > com.myplace.orm.mybatis.typehandlers.YorNToBoolean matches criteria > > > [is assignable to TypeHandler] - 1623 > > > 2010-08-26 10:30:54,207 DEBUG [main] java.sql.Connection - ooo > > > Connection Opened - 1663 > > > 2010-08-26 10:30:54,397 DEBUG [main] java.sql.PreparedStatement - > > > ==> Executing: select username, password, isenabled, > > > isaccountnonexpired, isaccountnonlocked, iscredentialsnonexpired, > > > first_name, last_name, address_line_1, address_line_2, city_name, > > > state, zip_code5 from users join persons on (username = person_id) > > > left outer join addresses a on (username = a.person_id and > > > a.address_type_code = 'A') where username = ? - 1853 > > > 2010-08-26 10:30:54,457 DEBUG [main] java.sql.PreparedStatement - ==> > > > Parameters: [hidden email](String) - 1913 > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > Columns: USERNAME, PASSWORD, ISENABLED, ISACCOUNTNONEXPIRED, > > > ISACCOUNTNONLOCKED, ISCREDENTIALSNONEXPIRED, FIRST_NAME, LAST_NAME, > > > ADDRESS_LINE_1, ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - 1953 > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > Row: [hidden email], xxxxxxx, Y, Y, Y, Y, Bozo, TheClown, 23rd > > > W. Park, Cubicle C, Boston, MA, 02114 - 1953 > > > 2010-08-26 10:30:54,517 DEBUG [main] java.sql.Connection - xxx > > > Connection Closed - 1973 > > > > On Aug 26, 7:29 am, Clinton Begin <[hidden email]> wrote: > > > > > What if you enable logging... can you see the statement being executed? > > > > Breakpoint in the constructor doesn't tell us much about what's going > > on in > > > > MyBatis. > > > > > On Wed, Aug 25, 2010 at 10:03 PM, Jim <[hidden email]> wrote: > > > > > No. I place a breakpoint in the Role constructor class then call the > > > > > getUserByUserName method but it never breaks and the rolesAdopted > > > > > property in the AuthorizedUser object is null. But if I invoke the > > > > > getUserRolesByUserName method independently - it works fine. Thanks > > > > > for you help. > > > > > > On Aug 25, 8:59 pm, Clinton Begin <[hidden email]> wrote: > > > > > > Can you tell if it's being called at all? > > > > > > > On Wed, Aug 25, 2010 at 7:35 PM, Jim <[hidden email]> > > wrote: > > > > > > > I have the following simple example that should be working > > > > > > > (independently they do) but the "many=@Many" result for the > > > > > > > rolesAdopted property (that should be calling the > > "getUserRolesByName" > > > > > > > and executing the constructor for instantiating an immutable > > type) > > > > > > > does not work. Any idea would be appreciated: > > > > > > > > @Select("select username, password, isenabled," + > > > > > > > " isaccountnonexpired, isaccountnonlocked, > > > > > > > iscredentialsnonexpired, " + > > > > > > > " first_name, last_name, " + > > > > > > > " address_line_1, address_line_2, " + > > > > > > > " city_name, state, zip_code5" + > > > > > > > " from users join persons on (username = > > person_id) " + > > > > > > > " left outer join addresses a on (username = > > a.person_id > > > > > > > and a.address_type_code = 'A') " + > > > > > > > " where username = #{userName}") > > > > > > > @Results(value = { > > > > > > > @Result(property="firstName", > > > > > > > column="first_name"), > > > > > > > @Result(property="lastName", > > > > > > > column="last_name"), > > > > > > > @Result(property="addressLine1", > > > > > > > column="address_line_1"), > > > > > > > @Result(property="addressLine2", > > > > > > > column="address_line_2"), > > > > > > > @Result(property="city", > > column="city_name"), > > > > > > > @Result(property="zipCode", > > column="zip_code5"), > > > > > > > @Result(property="rolesAdopted", > > > > > > > javaType=List.class, > > many=@Many(select="getUserRolesByUserName"))}) > > > > > > > List<AuthorizedUser> getUserByUserName(String userName); > > > > > > > > @Select("select username, authority, isenabled from > > authorities > > > > > > > where username = #{userName}") > > > > > > > @ConstructorArgs(value = { > > > > > > > @Arg(column="username",javaType=String.class), > > > > > > > @Arg(column="authority",javaType=String.class), > > > > > > > @Arg(column="isenabled", javaType=Boolean.class, > > > typeHandler=com.myplace.orm.mybatis.typehandlers.BooleanToYorN.class) > > > > > > > }) > > > > > > > List<Role> getUserRolesByUserName(String userName);- Hide > > quoted > > > > > text - > > > > > > > - Show quoted text -- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - |
|
Administrator
|
You can attach it to an issue in the issue tracker and then just let us know which one it is by replying to this thread.
Cheers, Clinton
On Mon, Aug 30, 2010 at 8:20 AM, Jim <[hidden email]> wrote: My unit tests are written against HSQLDB where would I submit the |
|
I have created issue defect # 91 and attached the requested
ManyIssuesProject.zip file. Thanks for your help in advanced. On Aug 30, 10:04 am, Clinton Begin <[hidden email]> wrote: > You can attach it to an issue in the issue tracker and then just let us know > which one it is by replying to this thread. > > Cheers, > Clinton > > > > On Mon, Aug 30, 2010 at 8:20 AM, Jim <[hidden email]> wrote: > > My unit tests are written against HSQLDB where would I submit the > > samples? Is there an email address or do I just attach it to this > > thread? Thanks. > > > On Aug 29, 6:27 pm, Clinton Begin <[hidden email]> wrote: > > > Since nobody is responding with a similar experience, the best thing to > > do > > > to speed up investigation on our end is for you to write an isolated unit > > > test against HSQLDB or Derby. Two databases are provided with the > > MyBatis > > > source code, so you don't have to create your own. Check out the source > > and > > > look for the "submitted" directory to see what others have done. > > > > Cheers, > > > Clinton > > > > On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]> wrote: > > > > Please let me know if I can provide additional details. Thanks for > > > > your help :) > > > > > On Aug 26, 10:36 am, Jim <[hidden email]> wrote: > > > > > Below is the log from calling the getUserByUserName method (as you > > can > > > > > see - the getUserRolesByUserName is not called). > > > > > > 2010-08-26 10:30:54,157 DEBUG [main] > > org.apache.ibatis.io.ResolverUtil > > > > > - Reader entry: BooleanToYorN.class - 1613 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Reader entry: YorNToBoolean.class > > > > > - 1623 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > com/myplace/orm/ > > > > > mybatis/typehandlers/BooleanToYorN.class - 1623 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > com/myplace/orm/ > > > > > mybatis/typehandlers/YorNToBoolean.class - 1623 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > com.myplace.orm.mybatis.typehandlers.BooleanToYorN matches criteria > > > > > [is assignable to TypeHandler] - 1623 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > com.myplace.orm.mybatis.typehandlers.YorNToBoolean matches criteria > > > > > [is assignable to TypeHandler] - 1623 > > > > > 2010-08-26 10:30:54,207 DEBUG [main] java.sql.Connection - ooo > > > > > Connection Opened - 1663 > > > > > 2010-08-26 10:30:54,397 DEBUG [main] java.sql.PreparedStatement - > > > > > ==> Executing: select username, password, isenabled, > > > > > isaccountnonexpired, isaccountnonlocked, iscredentialsnonexpired, > > > > > first_name, last_name, address_line_1, address_line_2, city_name, > > > > > state, zip_code5 from users join persons on (username = person_id) > > > > > left outer join addresses a on (username = a.person_id and > > > > > a.address_type_code = 'A') where username = ? - 1853 > > > > > 2010-08-26 10:30:54,457 DEBUG [main] java.sql.PreparedStatement - > > ==> > > > > > Parameters: [hidden email](String) - 1913 > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > Columns: USERNAME, PASSWORD, ISENABLED, ISACCOUNTNONEXPIRED, > > > > > ISACCOUNTNONLOCKED, ISCREDENTIALSNONEXPIRED, FIRST_NAME, LAST_NAME, > > > > > ADDRESS_LINE_1, ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - 1953 > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > Row: [hidden email], xxxxxxx, Y, Y, Y, Y, Bozo, TheClown, > > 23rd > > > > > W. Park, Cubicle C, Boston, MA, 02114 - 1953 > > > > > 2010-08-26 10:30:54,517 DEBUG [main] java.sql.Connection - xxx > > > > > Connection Closed - 1973 > > > > > > On Aug 26, 7:29 am, Clinton Begin <[hidden email]> wrote: > > > > > > > What if you enable logging... can you see the statement being > > executed? > > > > > > Breakpoint in the constructor doesn't tell us much about what's > > going > > > > on in > > > > > > MyBatis. > > > > > > > On Wed, Aug 25, 2010 at 10:03 PM, Jim <[hidden email]> > > wrote: > > > > > > > No. I place a breakpoint in the Role constructor class then call > > the > > > > > > > getUserByUserName method but it never breaks and the rolesAdopted > > > > > > > property in the AuthorizedUser object is null. But if I invoke > > the > > > > > > > getUserRolesByUserName method independently - it works fine. > > Thanks > > > > > > > for you help. > > > > > > > > On Aug 25, 8:59 pm, Clinton Begin <[hidden email]> > > wrote: > > > > > > > > Can you tell if it's being called at all? > > > > > > > > > On Wed, Aug 25, 2010 at 7:35 PM, Jim <[hidden email]> > > > > wrote: > > > > > > > > > I have the following simple example that should be working > > > > > > > > > (independently they do) but the "many=@Many" result for the > > > > > > > > > rolesAdopted property (that should be calling the > > > > "getUserRolesByName" > > > > > > > > > and executing the constructor for instantiating an immutable > > > > type) > > > > > > > > > does not work. Any idea would be appreciated: > > > > > > > > > > @Select("select username, password, isenabled," + > > > > > > > > > " isaccountnonexpired, isaccountnonlocked, > > > > > > > > > iscredentialsnonexpired, " + > > > > > > > > > " first_name, last_name, " + > > > > > > > > > " address_line_1, address_line_2, " + > > > > > > > > > " city_name, state, zip_code5" + > > > > > > > > > " from users join persons on (username = > > > > person_id) " + > > > > > > > > > " left outer join addresses a on (username = > > > > a.person_id > > > > > > > > > and a.address_type_code = 'A') " + > > > > > > > > > " where username = #{userName}") > > > > > > > > > @Results(value = { > > > > > > > > > @Result(property="firstName", > > > > > > > > > column="first_name"), > > > > > > > > > @Result(property="lastName", > > > > > > > > > column="last_name"), > > > > > > > > > @Result(property="addressLine1", > > > > > > > > > column="address_line_1"), > > > > > > > > > @Result(property="addressLine2", > > > > > > > > > column="address_line_2"), > > > > > > > > > @Result(property="city", > > > > column="city_name"), > > > > > > > > > @Result(property="zipCode", > > > > column="zip_code5"), > > > > > > > > > @Result(property="rolesAdopted", > > > > > > > > > javaType=List.class, > > > > many=@Many(select="getUserRolesByUserName"))}) > > > > > > > > > List<AuthorizedUser> getUserByUserName(String userName); > > > > > > > > > > @Select("select username, authority, isenabled from > > > > authorities > > > > > > > > > where username = #{userName}") > > > > > > > > > @ConstructorArgs(value = { > > > @Arg(column="username",javaType=String.class), > > > @Arg(column="authority",javaType=String.class), > > > > > > > > > @Arg(column="isenabled", > > javaType=Boolean.class, > > > > > typeHandler=com.myplace.orm.mybatis.typehandlers.BooleanToYorN.class) > > > > > > > > > }) > > > > > > > > > List<Role> getUserRolesByUserName(String userName);- Hide > > > > quoted > > > > > > > text - > > > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - |
|
Hi,everyone,
From your discussion,I see the annotation part in the code. When use MyBatis, we don't want to put the sql statment in java file. The XML is very easy for maintaince. Also the structure is clear. If we configure MyBatis with the annotation,of course it is convenient. Why write SQL in the annotation, I want to konw. Best Wishes! Nanlei 2010/8/31 Jim <[hidden email]> I have created issue defect # 91 and attached the requested |
|
I think it depends on who writes the code.
One advantage of annotations vs XML is that with annotations, you can directly see what SQL is executed as soon as you access the mapper's method. Using XML, you need to find the XML file that is linked to the mapper, open that file, and finally find the statement that is actually run on the DB (using IDE's search/find tool). I'm sure you can find many comparison between XML and annotations using Google. Christian ________________________________ De : [hidden email] [[hidden email]] de la part de 南磊 [[hidden email]] Date d'envoi : mercredi 1 septembre 2010 01:57 À : [hidden email] Objet : Re: @Many doesn't seem to be working Hi,everyone, From your discussion,I see the annotation part in the code. When use MyBatis, we don't want to put the sql statment in java file. The XML is very easy for maintaince. Also the structure is clear. If we configure MyBatis with the annotation,of course it is convenient. Why write SQL in the annotation, I want to konw. Best Wishes! Nanlei 2010/8/31 Jim <[hidden email]<mailto:[hidden email]>> I have created issue defect # 91 and attached the requested ManyIssuesProject.zip file. Thanks for your help in advanced. On Aug 30, 10:04 am, Clinton Begin <[hidden email]<mailto:[hidden email]>> wrote: > You can attach it to an issue in the issue tracker and then just let us know > which one it is by replying to this thread. > > Cheers, > Clinton > > > > On Mon, Aug 30, 2010 at 8:20 AM, Jim <[hidden email]<mailto:[hidden email]>> wrote: > > My unit tests are written against HSQLDB where would I submit the > > samples? Is there an email address or do I just attach it to this > > thread? Thanks. > > > On Aug 29, 6:27 pm, Clinton Begin <[hidden email]<mailto:[hidden email]>> wrote: > > > Since nobody is responding with a similar experience, the best thing to > > do > > > to speed up investigation on our end is for you to write an isolated unit > > > test against HSQLDB or Derby. Two databases are provided with the > > MyBatis > > > source code, so you don't have to create your own. Check out the source > > and > > > look for the "submitted" directory to see what others have done. > > > > Cheers, > > > Clinton > > > > On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]<mailto:[hidden email]>> wrote: > > > > Please let me know if I can provide additional details. Thanks for > > > > your help :) > > > > > On Aug 26, 10:36 am, Jim <[hidden email]<mailto:[hidden email]>> wrote: > > > > > Below is the log from calling the getUserByUserName method (as you > > can > > > > > see - the getUserRolesByUserName is not called). > > > > > > 2010-08-26 10:30:54,157 DEBUG [main] > > org.apache.ibatis.io.ResolverUtil > > > > > - Reader entry: BooleanToYorN.class - 1613 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Reader entry: YorNToBoolean.class > > > > > - 1623 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > com/myplace/orm/ > > > > > mybatis/typehandlers/BooleanToYorN.class - 1623 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > com/myplace/orm/ > > > > > mybatis/typehandlers/YorNToBoolean.class - 1623 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > com.myplace.orm.mybatis.typehandlers.BooleanToYorN matches criteria > > > > > [is assignable to TypeHandler] - 1623 > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > com.myplace.orm.mybatis.typehandlers.YorNToBoolean matches criteria > > > > > [is assignable to TypeHandler] - 1623 > > > > > 2010-08-26 10:30:54,207 DEBUG [main] java.sql.Connection - ooo > > > > > Connection Opened - 1663 > > > > > 2010-08-26 10:30:54,397 DEBUG [main] java.sql.PreparedStatement - > > > > > ==> Executing: select username, password, isenabled, > > > > > isaccountnonexpired, isaccountnonlocked, iscredentialsnonexpired, > > > > > first_name, last_name, address_line_1, address_line_2, city_name, > > > > > state, zip_code5 from users join persons on (username = person_id) > > > > > left outer join addresses a on (username = a.person_id and > > > > > a.address_type_code = 'A') where username = ? - 1853 > > > > > 2010-08-26 10:30:54,457 DEBUG [main] java.sql.PreparedStatement - > > ==> > > > > > Parameters: [hidden email]<mailto:[hidden email]>(String) - 1913 > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > Columns: USERNAME, PASSWORD, ISENABLED, ISACCOUNTNONEXPIRED, > > > > > ISACCOUNTNONLOCKED, ISCREDENTIALSNONEXPIRED, FIRST_NAME, LAST_NAME, > > > > > ADDRESS_LINE_1, ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - 1953 > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > Row: [hidden email]<mailto:[hidden email]>, xxxxxxx, Y, Y, Y, Y, Bozo, TheClown, > > 23rd > > > > > W. Park, Cubicle C, Boston, MA, 02114 - 1953 > > > > > 2010-08-26 10:30:54,517 DEBUG [main] java.sql.Connection - xxx > > > > > Connection Closed - 1973 > > > > > > On Aug 26, 7:29 am, Clinton Begin <[hidden email]<mailto:[hidden email]>> wrote: > > > > > > > What if you enable logging... can you see the statement being > > executed? > > > > > > Breakpoint in the constructor doesn't tell us much about what's > > going > > > > on in > > > > > > MyBatis. > > > > > > > On Wed, Aug 25, 2010 at 10:03 PM, Jim <[hidden email]<mailto:[hidden email]>> > > wrote: > > > > > > > No. I place a breakpoint in the Role constructor class then call > > the > > > > > > > getUserByUserName method but it never breaks and the rolesAdopted > > > > > > > property in the AuthorizedUser object is null. But if I invoke > > the > > > > > > > getUserRolesByUserName method independently - it works fine. > > Thanks > > > > > > > for you help. > > > > > > > > On Aug 25, 8:59 pm, Clinton Begin <[hidden email]<mailto:[hidden email]>> > > wrote: > > > > > > > > Can you tell if it's being called at all? > > > > > > > > > On Wed, Aug 25, 2010 at 7:35 PM, Jim <[hidden email]<mailto:[hidden email]>> > > > > wrote: > > > > > > > > > I have the following simple example that should be working > > > > > > > > > (independently they do) but the "many=@Many" result for the > > > > > > > > > rolesAdopted property (that should be calling the > > > > "getUserRolesByName" > > > > > > > > > and executing the constructor for instantiating an immutable > > > > type) > > > > > > > > > does not work. Any idea would be appreciated: > > > > > > > > > > @Select("select username, password, isenabled," + > > > > > > > > > " isaccountnonexpired, isaccountnonlocked, > > > > > > > > > iscredentialsnonexpired, " + > > > > > > > > > " first_name, last_name, " + > > > > > > > > > " address_line_1, address_line_2, " + > > > > > > > > > " city_name, state, zip_code5" + > > > > > > > > > " from users join persons on (username = > > > > person_id) " + > > > > > > > > > " left outer join addresses a on (username = > > > > a.person_id > > > > > > > > > and a.address_type_code = 'A') " + > > > > > > > > > " where username = #{userName}") > > > > > > > > > @Results(value = { > > > > > > > > > @Result(property="firstName", > > > > > > > > > column="first_name"), > > > > > > > > > @Result(property="lastName", > > > > > > > > > column="last_name"), > > > > > > > > > @Result(property="addressLine1", > > > > > > > > > column="address_line_1"), > > > > > > > > > @Result(property="addressLine2", > > > > > > > > > column="address_line_2"), > > > > > > > > > @Result(property="city", > > > > column="city_name"), > > > > > > > > > @Result(property="zipCode", > > > > column="zip_code5"), > > > > > > > > > @Result(property="rolesAdopted", > > > > > > > > > javaType=List.class, > > > > many=@Many(select="getUserRolesByUserName"))}) > > > > > > > > > List<AuthorizedUser> getUserByUserName(String userName); > > > > > > > > > > @Select("select username, authority, isenabled from > > > > authorities > > > > > > > > > where username = #{userName}") > > > > > > > > > @ConstructorArgs(value = { > > > @Arg(column="username",javaType=String.class), > > > @Arg(column="authority",javaType=String.class), > > > > > > > > > @Arg(column="isenabled", > > javaType=Boolean.class, > > > > > typeHandler=com.myplace.orm.mybatis.typehandlers.BooleanToYorN.class) > > > > > > > > > }) > > > > > > > > > List<Role> getUserRolesByUserName(String userName);- Hide > > > > quoted > > > > > > > text - > > > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - |
|
Sorry, I just not want to compare XML and annotation.
Years ago, I used the Spring JdbcTemplate to do the DB working , but the sql is written as string in the java class. Now with the MyBatis, the sql code is separated from the java file.So I like this greatest feature. If we write the sql back to class. Is it a good practice? I just want to know about this in details.
Best Wishes! Nanlei
2010/9/1 Poitras Christian <[hidden email]> I think it depends on who writes the code. |
|
I believe both are a good practice. I think it really depends on
the programmer or the company. Both solution work in MyBatis because no one is better than the
other! It purely depends on what you want to achieve. Personally, I use XML. Christian De :
[hidden email] [mailto:[hidden email]] De la
part de ?? Sorry, I just not want to compare XML and annotation. Years ago, I used the Spring JdbcTemplate to do the DB
working , but the sql is written as string in the java class. Now with the
MyBatis, the sql code is separated from the java file.So I like this greatest
feature. If we write the sql back to class. Is it a good practice? I just want
to know about this in details. Best Wishes!
Nanlei 2010/9/1 Poitras Christian <[hidden email]> I think it depends on who writes the code.
2010/8/31 Jim <[hidden email]<mailto:[hidden email]>> I have created issue defect #
91 and attached the requested On Aug 30, 10:04 am, Clinton Begin <[hidden email]<mailto:[hidden email]>>
wrote: > On Mon, Aug 30, 2010 at 8:20 AM, Jim <[hidden email]<mailto:[hidden email]>> wrote: > > On Aug 29, 6:27 pm, Clinton Begin <[hidden email]<mailto:[hidden email]>>
wrote: > > > On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]<mailto:[hidden email]>> wrote: > > > > On Aug 26, 10:36 am, Jim <[hidden email]<mailto:[hidden email]>> wrote: > > > > > Parameters: [hidden email]<mailto:[hidden email]>(String) - 1913 > > > > > 2010-08-26 10:30:54,497 DEBUG
[main] java.sql.ResultSet - <== > > > > > Row: [hidden email]<mailto:[hidden email]>, xxxxxxx, Y,
Y, Y, Y, Bozo, TheClown, > > 23rd > > > > > On Aug 26, 7:29 am, Clinton Begin
<[hidden email]<mailto:[hidden email]>>
wrote: > > > > > > On Wed, Aug 25, 2010 at 10:03
PM, Jim <[hidden email]<mailto:[hidden email]>> > > wrote: > > > > > > > On Aug 25, 8:59 pm,
Clinton Begin <[hidden email]<mailto:[hidden email]>> > > wrote: > > > > > > > > On Wed, Aug 25, 2010
at 7:35 PM, Jim <[hidden email]<mailto:[hidden email]>> > > > > wrote: |
|
Administrator
|
In reply to this post by nanlei1987
I personally use both. Annotations for simple one-liners, and XML for complicated queries and result sets.
Clinton
On Wed, Sep 1, 2010 at 7:31 AM, 南磊 <[hidden email]> wrote: Sorry, I just not want to compare XML and annotation. |
|
Administrator
|
In reply to this post by Jim
BTW Jim: Is it just the annotation, or does the equivalent XML mapping not work either?
Clinton
On Mon, Aug 30, 2010 at 11:52 PM, Jim <[hidden email]> wrote: I have created issue defect # 91 and attached the requested |
|
I use both as well. Our DAOMapperManager doesn't care if the mapper
comes from an annotated interface or XML configuration. I personally like the strong typing with the annotated interfaces and that it enables code completion in IDEs. I have attempted to use the following xml configuration but it does not work either: <select id="getUserByUserName" parameterType="String" resultMap="authorizedUserResultMap"> select username, password, first_name, last_name, address_line_1, address_line_2, city_name, state, zip_code5 from users join person on (username = person_id) left outer join address a on (username = a.person_id and a.address_type_code = 'A') where username = #{userName} </select> <resultMap id="authorizedUserResultMap" type="AuthorizedUser"> <result property="userName" column="username"/> <result property="password" column="password"/> <result property="firstName" column="first_name"/> <result property="lastName" column="last_name"/> <result property="addressLine1" column="address_line_1"/> <result property="addressLine2" column="address_line_2"/> <result property="city" column="city_name"/> <result property="state" column="state"/> <result property="zipCode" column="zip_code5"/> <collection property="rolesAdopted" ofType="Role" select="getUserRolesByUserName"> <constructor> <arg column="name" javaType="String"/> <arg column="authority" javaType="String"/> <arg column="enabled" javaType="Boolean"/> </constructor> </collection> </resultMap> <select id="getUserRolesByUserName" parameterType="String" resultMap="userRolesResultMap"> select username, authority, isenabled from user_authorities where username = #{userName} </select> <resultMap id="userRolesResultMap" type="Role"> <result property="name" column="username"/> <result property="authority" column="authority"/> <result property="isEnabled" column="isenabled" typeHandler="com.connector.framework.bridge.orm.mybatis.typehandlers.BooleanToYorN"/ > </resultMap> On Sep 1, 9:40 am, Clinton Begin <[hidden email]> wrote: > BTW Jim: Is it just the annotation, or does the equivalent XML mapping not > work either? > > Clinton > > > > On Mon, Aug 30, 2010 at 11:52 PM, Jim <[hidden email]> wrote: > > I have created issue defect # 91 and attached the requested > > ManyIssuesProject.zip file. Thanks for your help in advanced. > > > On Aug 30, 10:04 am, Clinton Begin <[hidden email]> wrote: > > > You can attach it to an issue in the issue tracker and then just let us > > know > > > which one it is by replying to this thread. > > > > Cheers, > > > Clinton > > > > On Mon, Aug 30, 2010 at 8:20 AM, Jim <[hidden email]> wrote: > > > > My unit tests are written against HSQLDB where would I submit the > > > > samples? Is there an email address or do I just attach it to this > > > > thread? Thanks. > > > > > On Aug 29, 6:27 pm, Clinton Begin <[hidden email]> wrote: > > > > > Since nobody is responding with a similar experience, the best thing > > to > > > > do > > > > > to speed up investigation on our end is for you to write an isolated > > unit > > > > > test against HSQLDB or Derby. Two databases are provided with the > > > > MyBatis > > > > > source code, so you don't have to create your own. Check out the > > source > > > > and > > > > > look for the "submitted" directory to see what others have done. > > > > > > Cheers, > > > > > Clinton > > > > > > On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]> wrote: > > > > > > Please let me know if I can provide additional details. Thanks for > > > > > > your help :) > > > > > > > On Aug 26, 10:36 am, Jim <[hidden email]> wrote: > > > > > > > Below is the log from calling the getUserByUserName method (as > > you > > > > can > > > > > > > see - the getUserRolesByUserName is not called). > > > > > > > > 2010-08-26 10:30:54,157 DEBUG [main] > > > > org.apache.ibatis.io.ResolverUtil > > > > > > > - Reader entry: BooleanToYorN.class - 1613 > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > org.apache.ibatis.io.ResolverUtil - Reader entry: > > YorNToBoolean.class > > > > > > > - 1623 > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > > > com/myplace/orm/ > > > > > > > mybatis/typehandlers/BooleanToYorN.class - 1623 > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > > > com/myplace/orm/ > > > > > > > mybatis/typehandlers/YorNToBoolean.class - 1623 > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > > > com.myplace.orm.mybatis.typehandlers.BooleanToYorN matches > > criteria > > > > > > > [is assignable to TypeHandler] - 1623 > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > > > com.myplace.orm.mybatis.typehandlers.YorNToBoolean matches > > criteria > > > > > > > [is assignable to TypeHandler] - 1623 > > > > > > > 2010-08-26 10:30:54,207 DEBUG [main] java.sql.Connection - ooo > > > > > > > Connection Opened - 1663 > > > > > > > 2010-08-26 10:30:54,397 DEBUG [main] java.sql.PreparedStatement > > - > > > > > > > ==> Executing: select username, password, isenabled, > > > > > > > isaccountnonexpired, isaccountnonlocked, iscredentialsnonexpired, > > > > > > > first_name, last_name, address_line_1, address_line_2, city_name, > > > > > > > state, zip_code5 from users join persons on (username = > > person_id) > > > > > > > left outer join addresses a on (username = a.person_id and > > > > > > > a.address_type_code = 'A') where username = ? - 1853 > > > > > > > 2010-08-26 10:30:54,457 DEBUG [main] java.sql.PreparedStatement > > - > > > > ==> > > > > > > > Parameters: [hidden email](String) - 1913 > > > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > > > Columns: USERNAME, PASSWORD, ISENABLED, ISACCOUNTNONEXPIRED, > > > > > > > ISACCOUNTNONLOCKED, ISCREDENTIALSNONEXPIRED, FIRST_NAME, > > LAST_NAME, > > > > > > > ADDRESS_LINE_1, ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - > > 1953 > > > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > > > Row: [hidden email], xxxxxxx, Y, Y, Y, Y, Bozo, TheClown, > > > > 23rd > > > > > > > W. Park, Cubicle C, Boston, MA, 02114 - 1953 > > > > > > > 2010-08-26 10:30:54,517 DEBUG [main] java.sql.Connection - xxx > > > > > > > Connection Closed - 1973 > > > > > > > > On Aug 26, 7:29 am, Clinton Begin <[hidden email]> > > wrote: > > > > > > > > > What if you enable logging... can you see the statement being > > > > executed? > > > > > > > > Breakpoint in the constructor doesn't tell us much about > > what's > > > > going > > > > > > on in > > > > > > > > MyBatis. > > > > > > > > > On Wed, Aug 25, 2010 at 10:03 PM, Jim <[hidden email]> > > > > wrote: > > > > > > > > > No. I place a breakpoint in the Role constructor class then > > call > > > > the > > > > > > > > > getUserByUserName method but it never breaks and the > > rolesAdopted > > > > > > > > > property in the AuthorizedUser object is null. But if I > > invoke > > > > the > > > > > > > > > getUserRolesByUserName method independently - it works fine. > > > > Thanks > > > > > > > > > for you help. > > > > > > > > > > On Aug 25, 8:59 pm, Clinton Begin <[hidden email]> > > > > wrote: > > > > > > > > > > Can you tell if it's being called at all? > > > > > > > > > > > On Wed, Aug 25, 2010 at 7:35 PM, Jim < > > [hidden email]> > > > > > > wrote: > > > > > > > > > > > I have the following simple example that should be > > working > > > > > > > > > > > (independently they do) but the "many=@Many" result for > > the > > > > > > > > > > > rolesAdopted property (that should be calling the > > > > > > "getUserRolesByName" > > > > > > > > > > > and executing the constructor for instantiating an > > immutable > > > > > > type) > > > > > > > > > > > does not work. Any idea would be appreciated: > > > > > > > > > > > > @Select("select username, password, isenabled," + > > > > > > > > > > > " isaccountnonexpired, isaccountnonlocked, > > > > > > > > > > > iscredentialsnonexpired, " + > > > > > > > > > > > " first_name, last_name, " + > > > > > > > > > > > " address_line_1, address_line_2, " + > > > > > > > > > > > " city_name, state, zip_code5" + > > > > > > > > > > > " from users join persons on (username = > > > > > > person_id) " + > > > > > > > > > > > " left outer join addresses a on (username = > > > > > > a.person_id > > > > > > > > > > > and a.address_type_code = 'A') " + > > > > > > > > > > > " where username = #{userName}") > > > > > > > > > > > @Results(value = { > > > > > > > > > > > @Result(property="firstName", > > > > > > > > > > > column="first_name"), > > > > > > > > > > > @Result(property="lastName", > > > > > > > > > > > column="last_name"), > > > > > > > > > > > @Result(property="addressLine1", > > > > > > > > > > > column="address_line_1"), > > > > > > > > > > > @Result(property="addressLine2", > > > > > > > > > > > column="address_line_2"), > > > > > > > > > > > @Result(property="city", > > > > > > column="city_name"), > > > > > > > > > > > @Result(property="zipCode", > > > > > > column="zip_code5"), > > > > > > > > > > > @Result(property="rolesAdopted", > > > > > > > > > > > javaType=List.class, > > > > > > many=@Many(select="getUserRolesByUserName"))}) > > > > > > > > > > > List<AuthorizedUser> getUserByUserName(String > > userName); > > > > > > > > > > > > @Select("select username, authority, isenabled from > > > > > > authorities > > > > > > > > > > > where username = #{userName}") > > > > > > > > > > > @ConstructorArgs(value = { > > > > > @Arg(column="username",javaType=String.class), > > > > > @Arg(column="authority",javaType=String.class), > > > > > > > > > > > @Arg(column="isenabled", > > > > javaType=Boolean.class, > > > typeHandler=com.myplace.orm.mybatis.typehandlers.BooleanToYorN.class) > > > > > > > > > > > }) > > > > > > > > > > > List<Role> getUserRolesByUserName(String userName);- > > Hide > > > > > > quoted > > > > > > > > > text - > > > > > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > > > - Show quoted text -- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - |
|
Here is the log from running the xml example. As you can see the
"getUserRolesByUserName" method is not called: log4j:ERROR Could not find value for key log4j.appender.FILE log4j:ERROR Could not instantiate appender named "FILE". log4j:WARN No appenders could be found for logger (org.springframework.context.support.FileSystemXmlApplicationContext). log4j:WARN Please initialize the log4j system properly. 2010-09-01 15:48:41,802 DEBUG [main] org.apache.ibatis.io.ResolverUtil - Reader entry: BooleanToYorN.class - 1833 2010-09-01 15:48:41,802 DEBUG [main] org.apache.ibatis.io.ResolverUtil - Reader entry: YorNToBoolean.class - 1833 2010-09-01 15:48:41,802 DEBUG [main] org.apache.ibatis.io.ResolverUtil - Found class file: com/connector/ framework/bridge/orm/mybatis/typehandlers/BooleanToYorN.class - 1833 2010-09-01 15:48:41,802 DEBUG [main] org.apache.ibatis.io.ResolverUtil - Found class file: com/connector/ framework/bridge/orm/mybatis/typehandlers/YorNToBoolean.class - 1833 2010-09-01 15:48:41,802 DEBUG [main] org.apache.ibatis.io.ResolverUtil - Checking to see if class com.connector.framework.bridge.orm.mybatis.typehandlers.BooleanToYorN matches criteria [is assignable to TypeHandler] - 1833 2010-09-01 15:48:41,862 DEBUG [main] org.apache.ibatis.io.ResolverUtil - Checking to see if class com.connector.framework.bridge.orm.mybatis.typehandlers.YorNToBoolean matches criteria [is assignable to TypeHandler] - 1893 2010-09-01 15:48:42,012 DEBUG [main] java.sql.Connection - ooo Connection Opened - 2043 2010-09-01 15:48:42,272 DEBUG [main] java.sql.PreparedStatement - ==> Executing: select username, password, first_name, last_name, address_line_1, address_line_2, city_name, state, zip_code5 from users join person on (username = person_id) left outer join address a on (username = a.person_id and a.address_type_code = 'A') where username = ? - 2303 2010-09-01 15:48:42,272 DEBUG [main] java.sql.PreparedStatement - ==> Parameters: [hidden email](String) - 2303 2010-09-01 15:48:42,332 DEBUG [main] java.sql.ResultSet - <== Columns: USERNAME, PASSWORD, FIRST_NAME, LAST_NAME, ADDRESS_LINE_1, ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - 2363 2010-09-01 15:48:42,332 DEBUG [main] java.sql.ResultSet - <== Row: [hidden email], xxxxxxx, Jim, Barnes, 2300 W. Plano Pkwy, Cubicle C, Plano, TX, 75075 - 2363 2010-09-01 15:48:42,342 DEBUG [main] java.sql.Connection - xxx Connection Closed - 2373 java.lang.RuntimeException: No authority defined for this user. On Sep 1, 3:44 pm, Jim <[hidden email]> wrote: > I use both as well. Our DAOMapperManager doesn't care if the mapper > comes from an annotated interface or XML configuration. I personally > like the strong typing with the annotated interfaces and that it > enables code completion in IDEs. > > I have attempted to use the following xml configuration but it does > not work either: > > <select id="getUserByUserName" parameterType="String" > resultMap="authorizedUserResultMap"> > select username, password, > first_name, last_name, address_line_1, address_line_2, > city_name, state, zip_code5 > from users join person on (username = person_id) > left outer join address a on (username = a.person_id and > a.address_type_code = 'A') > where username = #{userName} > </select> > > <resultMap id="authorizedUserResultMap" type="AuthorizedUser"> > <result property="userName" column="username"/> > <result property="password" column="password"/> > <result property="firstName" column="first_name"/> > <result property="lastName" column="last_name"/> > <result property="addressLine1" column="address_line_1"/> > <result property="addressLine2" column="address_line_2"/> > <result property="city" column="city_name"/> > <result property="state" column="state"/> > <result property="zipCode" column="zip_code5"/> > <collection property="rolesAdopted" ofType="Role" > select="getUserRolesByUserName"> > <constructor> > <arg column="name" javaType="String"/> > <arg column="authority" javaType="String"/> > <arg column="enabled" javaType="Boolean"/> > </constructor> > </collection> > </resultMap> > > <select id="getUserRolesByUserName" parameterType="String" > resultMap="userRolesResultMap"> > select username, authority, isenabled from user_authorities > where username = #{userName} > </select> > > <resultMap id="userRolesResultMap" type="Role"> > <result property="name" column="username"/> > <result property="authority" column="authority"/> > <result property="isEnabled" column="isenabled" > typeHandler="com.connector.framework.bridge.orm.mybatis.typehandlers.BooleanToYorN"/ > > </resultMap> > > On Sep 1, 9:40 am, Clinton Begin <[hidden email]> wrote: > > > > > BTW Jim: Is it just the annotation, or does the equivalent XML mapping not > > work either? > > > Clinton > > > On Mon, Aug 30, 2010 at 11:52 PM, Jim <[hidden email]> wrote: > > > I have created issue defect # 91 and attached the requested > > > ManyIssuesProject.zip file. Thanks for your help in advanced. > > > > On Aug 30, 10:04 am, Clinton Begin <[hidden email]> wrote: > > > > You can attach it to an issue in the issue tracker and then just let us > > > know > > > > which one it is by replying to this thread. > > > > > Cheers, > > > > Clinton > > > > > On Mon, Aug 30, 2010 at 8:20 AM, Jim <[hidden email]> wrote: > > > > > My unit tests are written against HSQLDB where would I submit the > > > > > samples? Is there an email address or do I just attach it to this > > > > > thread? Thanks. > > > > > > On Aug 29, 6:27 pm, Clinton Begin <[hidden email]> wrote: > > > > > > Since nobody is responding with a similar experience, the best thing > > > to > > > > > do > > > > > > to speed up investigation on our end is for you to write an isolated > > > unit > > > > > > test against HSQLDB or Derby. Two databases are provided with the > > > > > MyBatis > > > > > > source code, so you don't have to create your own. Check out the > > > source > > > > > and > > > > > > look for the "submitted" directory to see what others have done. > > > > > > > Cheers, > > > > > > Clinton > > > > > > > On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]> wrote: > > > > > > > Please let me know if I can provide additional details. Thanks for > > > > > > > your help :) > > > > > > > > On Aug 26, 10:36 am, Jim <[hidden email]> wrote: > > > > > > > > Below is the log from calling the getUserByUserName method (as > > > you > > > > > can > > > > > > > > see - the getUserRolesByUserName is not called). > > > > > > > > > 2010-08-26 10:30:54,157 DEBUG [main] > > > > > org.apache.ibatis.io.ResolverUtil > > > > > > > > - Reader entry: BooleanToYorN.class - 1613 > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > org.apache.ibatis.io.ResolverUtil - Reader entry: > > > YorNToBoolean.class > > > > > > > > - 1623 > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > > > > com/myplace/orm/ > > > > > > > > mybatis/typehandlers/BooleanToYorN.class - 1623 > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > > > > com/myplace/orm/ > > > > > > > > mybatis/typehandlers/YorNToBoolean.class - 1623 > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > > > > com.myplace.orm.mybatis.typehandlers.BooleanToYorN matches > > > criteria > > > > > > > > [is assignable to TypeHandler] - 1623 > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > > > > com.myplace.orm.mybatis.typehandlers.YorNToBoolean matches > > > criteria > > > > > > > > [is assignable to TypeHandler] - 1623 > > > > > > > > 2010-08-26 10:30:54,207 DEBUG [main] java.sql.Connection - ooo > > > > > > > > Connection Opened - 1663 > > > > > > > > 2010-08-26 10:30:54,397 DEBUG [main] java.sql.PreparedStatement > > > - > > > > > > > > ==> Executing: select username, password, isenabled, > > > > > > > > isaccountnonexpired, isaccountnonlocked, iscredentialsnonexpired, > > > > > > > > first_name, last_name, address_line_1, address_line_2, city_name, > > > > > > > > state, zip_code5 from users join persons on (username = > > > person_id) > > > > > > > > left outer join addresses a on (username = a.person_id and > > > > > > > > a.address_type_code = 'A') where username = ? - 1853 > > > > > > > > 2010-08-26 10:30:54,457 DEBUG [main] java.sql.PreparedStatement > > > - > > > > > ==> > > > > > > > > Parameters: [hidden email](String) - 1913 > > > > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > > > > Columns: USERNAME, PASSWORD, ISENABLED, ISACCOUNTNONEXPIRED, > > > > > > > > ISACCOUNTNONLOCKED, ISCREDENTIALSNONEXPIRED, FIRST_NAME, > > > LAST_NAME, > > > > > > > > ADDRESS_LINE_1, ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - > > > 1953 > > > > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > > > > Row: [hidden email], xxxxxxx, Y, Y, Y, Y, Bozo, TheClown, > > > > > 23rd > > > > > > > > W. Park, Cubicle C, Boston, MA, 02114 - 1953 > > > > > > > > 2010-08-26 10:30:54,517 DEBUG [main] java.sql.Connection - xxx > > > > > > > > Connection Closed - 1973 > > > > > > > > > On Aug 26, 7:29 am, Clinton Begin <[hidden email]> > > > wrote: > > > > > > > > > > What if you enable logging... can you see the statement being > > > > > executed? > > > > > > > > > Breakpoint in the constructor doesn't tell us much about > > > what's > > > > > going > > > > > > > on in > > > > > > > > > MyBatis. > > > > > > > > > > On Wed, Aug 25, 2010 at 10:03 PM, Jim <[hidden email]> > > > > > wrote: > > > > > > > > > > No. I place a breakpoint in the Role constructor class then > > > call > > > > > the > > > > > > > > > > getUserByUserName method but it never breaks and the > > > rolesAdopted > > > > > > > > > > property in the AuthorizedUser object is null. But if I > > > invoke > > > > > the > > > > > > > > > > getUserRolesByUserName method independently - it works fine. > > > > > Thanks > > > > > > > > > > for you help. > > > > > > > > > > > On Aug 25, 8:59 pm, Clinton Begin <[hidden email]> > > > > > wrote: > > > > > > > > > > > Can you tell if it's being called at all? > > > > > > > > > > > > On Wed, Aug 25, 2010 at 7:35 PM, Jim < > > > [hidden email]> > > > > > > > wrote: > > > > > > > > > > > > I have the following simple example that should be > > > working > > > > > > > > > > > > (independently they do) but the "many=@Many" result for > > > the > > > > > > > > > > > > rolesAdopted property (that should be calling the > > > > > > > "getUserRolesByName" > > > > > > > > > > > > and executing the constructor for instantiating an > > > immutable > > > > > > > type) > > > > > > > > > > > > does not work. Any idea would be appreciated: > > > > > > > > > > > > > @Select("select username, password, isenabled," + > > > > > > > > > > > > " isaccountnonexpired, isaccountnonlocked, > > > > > > > > > > > > iscredentialsnonexpired, " + > > > > > > > > > > > > " first_name, last_name, " + > > > > > > > > > > > > " address_line_1, address_line_2, " + > > > > > > > > > > > > " city_name, state, zip_code5" + > > > > > > > > > > > > " from users join persons on (username = > > > > > > > person_id) " + > > > > > > > > > > > > " left outer join addresses a on (username = > > > > > > > a.person_id > > > > > > > > > > > > and a.address_type_code = 'A') " + > > > > > > > > > > > > " where username = #{userName}") > > > > > > > > > > > > @Results(value = { > > > > > > > > > > > > @Result(property="firstName", > > > > > > > > > > > > column="first_name"), > > > > > > > > > > > > @Result(property="lastName", > > > > > > > > > > > > column="last_name"), > > > > > > > > > > > > @Result(property="addressLine1", > > > > > > > > > > > > column="address_line_1"), > > > > > > > > > > > > @Result(property="addressLine2", > > > > > > > > > > > > column="address_line_2"), > > > > > > > > > > > > @Result(property="city", > > > > > > > column="city_name"), > > ... > > read more »- Hide quoted text - > > - Show quoted text - |
|
This xml example does work but is not exactly the same as @Many:
<select id="getUserByUserName" parameterType="String" resultMap="authorizedUserResultMap"> select u.username, u.password, first_name, last_name, address_line_1, address_line_2, city_name, state, zip_code5, authority, isenabled from users u join person on (u.username = person_id) left outer join address a on (u.username = a.person_id and a.address_type_code = 'A') left outer join user_authorities ua on (u.username = ua.username) where username = #{userName} </select> <resultMap id="authorizedUserResultMap" type="AuthorizedUser"> <result property="userName" column="username"/> <result property="password" column="password"/> <result property="firstName" column="first_name"/> <result property="lastName" column="last_name"/> <result property="addressLine1" column="address_line_1"/> <result property="addressLine2" column="address_line_2"/> <result property="city" column="city_name"/> <result property="state" column="state"/> <result property="zipCode" column="zip_code5"/> <collection property="rolesAdopted" ofType="Role" resultMap="userRolesResultMap"/> </resultMap> <select id="getUserRolesByUserName" parameterType="String" resultMap="userRolesResultMap"> select username, authority, isenabled from user_authorities where username = #{userName} </select> <resultMap id="userRolesResultMap" type="Role"> <constructor> <arg column="username" javaType="String"/> <arg column="authority" javaType="String"/> <arg column="isenabled" javaType="Boolean" typeHandler="com.connector.framework.bridge.orm.mybatis.typehandlers.BooleanToYorN"/ > </constructor> </resultMap> On Sep 1, 3:54 pm, Jim <[hidden email]> wrote: > Here is the log from running the xml example. As you can see the > "getUserRolesByUserName" method is not called: > > log4j:ERROR Could not find value for key log4j.appender.FILE > log4j:ERROR Could not instantiate appender named "FILE". > log4j:WARN No appenders could be found for logger > (org.springframework.context.support.FileSystemXmlApplicationContext). > log4j:WARN Please initialize the log4j system properly. > 2010-09-01 15:48:41,802 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Reader entry: BooleanToYorN.class > - 1833 > 2010-09-01 15:48:41,802 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Reader entry: YorNToBoolean.class > - 1833 > 2010-09-01 15:48:41,802 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Found class file: com/connector/ > framework/bridge/orm/mybatis/typehandlers/BooleanToYorN.class - 1833 > 2010-09-01 15:48:41,802 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Found class file: com/connector/ > framework/bridge/orm/mybatis/typehandlers/YorNToBoolean.class - 1833 > 2010-09-01 15:48:41,802 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Checking to see if class > com.connector.framework.bridge.orm.mybatis.typehandlers.BooleanToYorN > matches criteria [is assignable to TypeHandler] - 1833 > 2010-09-01 15:48:41,862 DEBUG [main] > org.apache.ibatis.io.ResolverUtil - Checking to see if class > com.connector.framework.bridge.orm.mybatis.typehandlers.YorNToBoolean > matches criteria [is assignable to TypeHandler] - 1893 > 2010-09-01 15:48:42,012 DEBUG [main] java.sql.Connection - ooo > Connection Opened - 2043 > 2010-09-01 15:48:42,272 DEBUG [main] java.sql.PreparedStatement - > ==> Executing: select username, password, first_name, last_name, > address_line_1, address_line_2, city_name, state, zip_code5 from users > join person on (username = person_id) left outer join address a on > (username = a.person_id and a.address_type_code = 'A') where username > = ? - 2303 > 2010-09-01 15:48:42,272 DEBUG [main] java.sql.PreparedStatement - ==> > Parameters: [hidden email](String) - 2303 > 2010-09-01 15:48:42,332 DEBUG [main] java.sql.ResultSet - <== > Columns: USERNAME, PASSWORD, FIRST_NAME, LAST_NAME, ADDRESS_LINE_1, > ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - 2363 > 2010-09-01 15:48:42,332 DEBUG [main] java.sql.ResultSet - <== > Row: [hidden email], xxxxxxx, Jim, Barnes, 2300 W. Plano Pkwy, > Cubicle C, Plano, TX, 75075 - 2363 > 2010-09-01 15:48:42,342 DEBUG [main] java.sql.Connection - xxx > Connection Closed - 2373 > java.lang.RuntimeException: No authority defined for this user. > > On Sep 1, 3:44 pm, Jim <[hidden email]> wrote:> I use both as well. Our DAOMapperManager doesn't care if the mapper > > comes from an annotated interface or XML configuration. I personally > > like the strong typing with the annotated interfaces and that it > > enables code completion in IDEs. > > > I have attempted to use the following xml configuration but it does > > not work either: > > > <select id="getUserByUserName" parameterType="String" > > resultMap="authorizedUserResultMap"> > > select username, password, > > first_name, last_name, address_line_1, address_line_2, > > city_name, state, zip_code5 > > from users join person on (username = person_id) > > left outer join address a on (username = a.person_id and > > a.address_type_code = 'A') > > where username = #{userName} > > </select> > > > <resultMap id="authorizedUserResultMap" type="AuthorizedUser"> > > <result property="userName" column="username"/> > > <result property="password" column="password"/> > > <result property="firstName" column="first_name"/> > > <result property="lastName" column="last_name"/> > > <result property="addressLine1" column="address_line_1"/> > > <result property="addressLine2" column="address_line_2"/> > > <result property="city" column="city_name"/> > > <result property="state" column="state"/> > > <result property="zipCode" column="zip_code5"/> > > <collection property="rolesAdopted" ofType="Role" > > select="getUserRolesByUserName"> > > <constructor> > > <arg column="name" javaType="String"/> > > <arg column="authority" javaType="String"/> > > <arg column="enabled" javaType="Boolean"/> > > </constructor> > > </collection> > > </resultMap> > > > <select id="getUserRolesByUserName" parameterType="String" > > resultMap="userRolesResultMap"> > > select username, authority, isenabled from user_authorities > > where username = #{userName} > > </select> > > > <resultMap id="userRolesResultMap" type="Role"> > > <result property="name" column="username"/> > > <result property="authority" column="authority"/> > > <result property="isEnabled" column="isenabled" > > typeHandler="com.connector.framework.bridge.orm.mybatis.typehandlers.BooleanToYorN"/ > > > </resultMap> > > > On Sep 1, 9:40 am, Clinton Begin <[hidden email]> wrote: > > > > BTW Jim: Is it just the annotation, or does the equivalent XML mapping not > > > work either? > > > > Clinton > > > > On Mon, Aug 30, 2010 at 11:52 PM, Jim <[hidden email]> wrote: > > > > I have created issue defect # 91 and attached the requested > > > > ManyIssuesProject.zip file. Thanks for your help in advanced. > > > > > On Aug 30, 10:04 am, Clinton Begin <[hidden email]> wrote: > > > > > You can attach it to an issue in the issue tracker and then just let us > > > > know > > > > > which one it is by replying to this thread. > > > > > > Cheers, > > > > > Clinton > > > > > > On Mon, Aug 30, 2010 at 8:20 AM, Jim <[hidden email]> wrote: > > > > > > My unit tests are written against HSQLDB where would I submit the > > > > > > samples? Is there an email address or do I just attach it to this > > > > > > thread? Thanks. > > > > > > > On Aug 29, 6:27 pm, Clinton Begin <[hidden email]> wrote: > > > > > > > Since nobody is responding with a similar experience, the best thing > > > > to > > > > > > do > > > > > > > to speed up investigation on our end is for you to write an isolated > > > > unit > > > > > > > test against HSQLDB or Derby. Two databases are provided with the > > > > > > MyBatis > > > > > > > source code, so you don't have to create your own. Check out the > > > > source > > > > > > and > > > > > > > look for the "submitted" directory to see what others have done. > > > > > > > > Cheers, > > > > > > > Clinton > > > > > > > > On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]> wrote: > > > > > > > > Please let me know if I can provide additional details. Thanks for > > > > > > > > your help :) > > > > > > > > > On Aug 26, 10:36 am, Jim <[hidden email]> wrote: > > > > > > > > > Below is the log from calling the getUserByUserName method (as > > > > you > > > > > > can > > > > > > > > > see - the getUserRolesByUserName is not called). > > > > > > > > > > 2010-08-26 10:30:54,157 DEBUG [main] > > > > > > org.apache.ibatis.io.ResolverUtil > > > > > > > > > - Reader entry: BooleanToYorN.class - 1613 > > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > > org.apache.ibatis.io.ResolverUtil - Reader entry: > > > > YorNToBoolean.class > > > > > > > > > - 1623 > > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > > > > > com/myplace/orm/ > > > > > > > > > mybatis/typehandlers/BooleanToYorN.class - 1623 > > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > > > > > com/myplace/orm/ > > > > > > > > > mybatis/typehandlers/YorNToBoolean.class - 1623 > > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > > > > > com.myplace.orm.mybatis.typehandlers.BooleanToYorN matches > > > > criteria > > > > > > > > > [is assignable to TypeHandler] - 1623 > > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > > > > > > > > com.myplace.orm.mybatis.typehandlers.YorNToBoolean matches > > > > criteria > > > > > > > > > [is assignable to TypeHandler] - 1623 > > > > > > > > > 2010-08-26 10:30:54,207 DEBUG [main] java.sql.Connection - ooo > > > > > > > > > Connection Opened - 1663 > > > > > > > > > 2010-08-26 10:30:54,397 DEBUG [main] java.sql.PreparedStatement > > > > - > > > > > > > > > ==> Executing: select username, password, isenabled, > > > > > > > > > isaccountnonexpired, isaccountnonlocked, iscredentialsnonexpired, > > > > > > > > > first_name, last_name, address_line_1, address_line_2, city_name, > > > > > > > > > state, zip_code5 from users join persons on (username = > > > > person_id) > > > > > > > > > left outer join addresses a on (username = a.person_id and > > > > > > > > > a.address_type_code = 'A') where username = ? - 1853 > > > > > > > > > 2010-08-26 10:30:54,457 DEBUG [main] java.sql.PreparedStatement > > > > - > > > > > > ==> > > > > > > > > > Parameters: [hidden email](String) - 1913 > > > > > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > > > > > Columns: USERNAME, PASSWORD, ISENABLED, ISACCOUNTNONEXPIRED, > > > > > > > > > ISACCOUNTNONLOCKED, ISCREDENTIALSNONEXPIRED, FIRST_NAME, > > > > LAST_NAME, > > > > > > > > > ADDRESS_LINE_1, ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - > > > > 1953 > > > > > > > > > 2010-08-26 10:30:54,497 DEBUG [main] java.sql.ResultSet - <== > > > > > > > > > Row: [hidden email], xxxxxxx, Y, Y, Y, Y, Bozo, TheClown, > > > > > > 23rd > > > > > > > > > W. Park, Cubicle C, Boston, MA, 02114 - 1953 > > > > > > > > > 2010-08-26 10:30:54,517 DEBUG [main] java.sql.Connection - xxx > > > > > > > > > Connection Closed - 1973 > > > > > > > > > > On Aug 26, 7:29 am, Clinton Begin <[hidden email]> > > > > wrote: > > > > > > > > > > > What if you enable logging... can you see the statement being > > > > > > executed? > > > > > > > > > > Breakpoint in the constructor doesn't tell us much about > > > > what's > > > > > > going > > > > > > > > on in > > > > > > > > > > MyBatis. > > > > > > > > > > > On Wed, Aug 25, 2010 at 10:03 PM, Jim <[hidden email]> > > > > > > wrote: > > > > > > > > > > > No. I place a breakpoint in the Role constructor class then > > > > call > > > > > > the > > > > > > > > > > > getUserByUserName method but it never breaks and the > > > > rolesAdopted > > > > > > > > > > > property in the AuthorizedUser object is null. But if I > > > > invoke > > > > > > the > > > > > > > > > > > getUserRolesByUserName method independently - it works fine. > > > > > > Thanks > > > > > > > > > > > for you help. > > > > > > > > > > > > On Aug 25, 8:59 pm, Clinton Begin <[hidden email]> > > > > > > wrote: > > > > > > > > > > > > Can you tell if it's being called at all? > > > > > > > > > > > > > On Wed, Aug 25, 2010 at 7:35 PM, Jim < > > > > [hidden email]> > > > > > > > > wrote: > > > > > > > > > > > > > I have the following simple example that should be > > > > working > > > > > > > > > > > > > (independently they do) but the "many=@Many" result for > > > > the > > > > > > > > > > > > > rolesAdopted property (that should be calling the > > > > > > > > "getUserRolesByName" > > > > > > > > > > > > > and executing the constructor for instantiating an > > > > immutable > > > > > > > > type) > > > > > > > > > > > > > does not work. Any idea would be appreciated: > > > > > > > > > > > > > > @Select("select username, password, isenabled," + > > > > > > > > > > > > > " isaccountnonexpired, isaccountnonlocked, > > > > > > > > > > > > > iscredentialsnonexpired, " + > > > > > > > > > > > > > " first_name, last_name, " + > > > > > > > > > > > > > " address_line_1, address_line_2, " + > > > > > > > > > > > > > " city_name, state, zip_code5" + > > > > > > > > > > > > > " from users join persons on (username = > > > > > > > > person_id) " + > > > > > > > > > > > > > " left outer join addresses a on (username = > > > > > > > > a.person_id > > > > > > > > > > > > > and a.address_type_code = 'A') " + > > > > > > > > > > > > > " where username = #{userName}") > > > > > > > > > > > > > @Results(value = { > > > > > > > > > > > > > @Result(property="firstName", > > > > > > > > > > > > > column="first_name"), > > > > > > > > > > > > > @Result(property="lastName", > > > > > > > > > > > > > column="last_name"), > > > > > > > > > > > > > @Result(property="addressLine1", > > > > > > > > > > > > > column="address_line_1"), > > > > > > > > > > > > > @Result(property="addressLine2", > > > > > > > > > > > > > column="address_line_2"), > > > > > > > > > > > > > @Result(property="city", > > > > > > > > column="city_name"), > > > ... > > > read more »- Hide quoted text - > > > - Show quoted text - |
|
Administrator
|
I just updated the issue #91 in the issue tracker with the results.
Cheers, Clinton On Sep 3, 3:59 pm, Jim <[hidden email]> wrote: > This xml example does work but is not exactly the same as @Many: > > <select id="getUserByUserName" parameterType="String" > resultMap="authorizedUserResultMap"> > select u.username, u.password, > first_name, last_name, address_line_1, address_line_2, > city_name, state, zip_code5, > authority, isenabled > from users u join person on (u.username = person_id) > left outer join address a on (u.username = a.person_id and > a.address_type_code = 'A') > left outer join user_authorities ua on (u.username = > ua.username) > where username = #{userName} > </select> > > <resultMap id="authorizedUserResultMap" type="AuthorizedUser"> > <result property="userName" column="username"/> > <result property="password" column="password"/> > <result property="firstName" column="first_name"/> > <result property="lastName" column="last_name"/> > <result property="addressLine1" column="address_line_1"/> > <result property="addressLine2" column="address_line_2"/> > <result property="city" column="city_name"/> > <result property="state" column="state"/> > <result property="zipCode" column="zip_code5"/> > <collection property="rolesAdopted" ofType="Role" > resultMap="userRolesResultMap"/> > </resultMap> > > <select id="getUserRolesByUserName" parameterType="String" > resultMap="userRolesResultMap"> > select username, authority, isenabled from user_authorities > where username = #{userName} > </select> > > <resultMap id="userRolesResultMap" type="Role"> > <constructor> > <arg column="username" javaType="String"/> > <arg column="authority" javaType="String"/> > <arg column="isenabled" javaType="Boolean" > typeHandler="com.connector.framework.bridge.orm.mybatis.typehandlers.Boolea nToYorN"/ > > </constructor> > </resultMap> > > On Sep 1, 3:54 pm, Jim <[hidden email]> wrote: > > > > > Here is the log from running the xml example. As you can see the > > "getUserRolesByUserName" method is not called: > > > log4j:ERROR Could not find value for key log4j.appender.FILE > > log4j:ERROR Could not instantiate appender named "FILE". > > log4j:WARN No appenders could be found for logger > > (org.springframework.context.support.FileSystemXmlApplicationContext). > > log4j:WARN Please initialize the log4j system properly. > > 2010-09-01 15:48:41,802 DEBUG [main] > > org.apache.ibatis.io.ResolverUtil - Reader entry: BooleanToYorN.class > > - 1833 > > 2010-09-01 15:48:41,802 DEBUG [main] > > org.apache.ibatis.io.ResolverUtil - Reader entry: YorNToBoolean.class > > - 1833 > > 2010-09-01 15:48:41,802 DEBUG [main] > > org.apache.ibatis.io.ResolverUtil - Found class file: com/connector/ > > framework/bridge/orm/mybatis/typehandlers/BooleanToYorN.class - 1833 > > 2010-09-01 15:48:41,802 DEBUG [main] > > org.apache.ibatis.io.ResolverUtil - Found class file: com/connector/ > > framework/bridge/orm/mybatis/typehandlers/YorNToBoolean.class - 1833 > > 2010-09-01 15:48:41,802 DEBUG [main] > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > com.connector.framework.bridge.orm.mybatis.typehandlers.BooleanToYorN > > matches criteria [is assignable to TypeHandler] - 1833 > > 2010-09-01 15:48:41,862 DEBUG [main] > > org.apache.ibatis.io.ResolverUtil - Checking to see if class > > com.connector.framework.bridge.orm.mybatis.typehandlers.YorNToBoolean > > matches criteria [is assignable to TypeHandler] - 1893 > > 2010-09-01 15:48:42,012 DEBUG [main] java.sql.Connection - ooo > > Connection Opened - 2043 > > 2010-09-01 15:48:42,272 DEBUG [main] java.sql.PreparedStatement - > > ==> Executing: select username, password, first_name, last_name, > > address_line_1, address_line_2, city_name, state, zip_code5 from users > > join person on (username = person_id) left outer join address a on > > (username = a.person_id and a.address_type_code = 'A') where username > > = ? - 2303 > > 2010-09-01 15:48:42,272 DEBUG [main] java.sql.PreparedStatement - ==> > > Parameters: [hidden email](String) - 2303 > > 2010-09-01 15:48:42,332 DEBUG [main] java.sql.ResultSet - <== > > Columns: USERNAME, PASSWORD, FIRST_NAME, LAST_NAME, ADDRESS_LINE_1, > > ADDRESS_LINE_2, CITY_NAME, STATE, ZIP_CODE5 - 2363 > > 2010-09-01 15:48:42,332 DEBUG [main] java.sql.ResultSet - <== > > Row: [hidden email], xxxxxxx, Jim, Barnes, 2300 W. Plano Pkwy, > > Cubicle C, Plano, TX, 75075 - 2363 > > 2010-09-01 15:48:42,342 DEBUG [main] java.sql.Connection - xxx > > Connection Closed - 2373 > > java.lang.RuntimeException: No authority defined for this user. > > > On Sep 1, 3:44 pm, Jim <[hidden email]> wrote:> I use both as well. Our DAOMapperManager doesn't care if the mapper > > > comes from an annotated interface or XML configuration. I personally > > > like the strong typing with the annotated interfaces and that it > > > enables code completion in IDEs. > > > > I have attempted to use the following xml configuration but it does > > > not work either: > > > > <select id="getUserByUserName" parameterType="String" > > > resultMap="authorizedUserResultMap"> > > > select username, password, > > > first_name, last_name, address_line_1, address_line_2, > > > city_name, state, zip_code5 > > > from users join person on (username = person_id) > > > left outer join address a on (username = a.person_id and > > > a.address_type_code = 'A') > > > where username = #{userName} > > > </select> > > > > <resultMap id="authorizedUserResultMap" type="AuthorizedUser"> > > > <result property="userName" column="username"/> > > > <result property="password" column="password"/> > > > <result property="firstName" column="first_name"/> > > > <result property="lastName" column="last_name"/> > > > <result property="addressLine1" column="address_line_1"/> > > > <result property="addressLine2" column="address_line_2"/> > > > <result property="city" column="city_name"/> > > > <result property="state" column="state"/> > > > <result property="zipCode" column="zip_code5"/> > > > <collection property="rolesAdopted" ofType="Role" > > > select="getUserRolesByUserName"> > > > <constructor> > > > <arg column="name" javaType="String"/> > > > <arg column="authority" javaType="String"/> > > > <arg column="enabled" javaType="Boolean"/> > > > </constructor> > > > </collection> > > > </resultMap> > > > > <select id="getUserRolesByUserName" parameterType="String" > > > resultMap="userRolesResultMap"> > > > select username, authority, isenabled from user_authorities > > > where username = #{userName} > > > </select> > > > > <resultMap id="userRolesResultMap" type="Role"> > > > <result property="name" column="username"/> > > > <result property="authority" column="authority"/> > > > <result property="isEnabled" column="isenabled" > > > typeHandler="com.connector.framework.bridge.orm.mybatis.typehandlers.Boolea nToYorN"/ > > > > </resultMap> > > > > On Sep 1, 9:40 am, Clinton Begin <[hidden email]> wrote: > > > > > BTW Jim: Is it just the annotation, or does the equivalent XML mapping not > > > > work either? > > > > > Clinton > > > > > On Mon, Aug 30, 2010 at 11:52 PM, Jim <[hidden email]> wrote: > > > > > I have created issue defect # 91 and attached the requested > > > > > ManyIssuesProject.zip file. Thanks for your help in advanced. > > > > > > On Aug 30, 10:04 am, Clinton Begin <[hidden email]> wrote: > > > > > > You can attach it to an issue in the issue tracker and then just let us > > > > > know > > > > > > which one it is by replying to this thread. > > > > > > > Cheers, > > > > > > Clinton > > > > > > > On Mon, Aug 30, 2010 at 8:20 AM, Jim <[hidden email]> wrote: > > > > > > > My unit tests are written against HSQLDB where would I submit the > > > > > > > samples? Is there an email address or do I just attach it to this > > > > > > > thread? Thanks. > > > > > > > > On Aug 29, 6:27 pm, Clinton Begin <[hidden email]> wrote: > > > > > > > > Since nobody is responding with a similar experience, the best thing > > > > > to > > > > > > > do > > > > > > > > to speed up investigation on our end is for you to write an isolated > > > > > unit > > > > > > > > test against HSQLDB or Derby. Two databases are provided with the > > > > > > > MyBatis > > > > > > > > source code, so you don't have to create your own. Check out the > > > > > source > > > > > > > and > > > > > > > > look for the "submitted" directory to see what others have done. > > > > > > > > > Cheers, > > > > > > > > Clinton > > > > > > > > > On Fri, Aug 27, 2010 at 4:31 PM, Jim <[hidden email]> wrote: > > > > > > > > > Please let me know if I can provide additional details. Thanks for > > > > > > > > > your help :) > > > > > > > > > > On Aug 26, 10:36 am, Jim <[hidden email]> wrote: > > > > > > > > > > Below is the log from calling the getUserByUserName method (as > > > > > you > > > > > > > can > > > > > > > > > > see - the getUserRolesByUserName is not called). > > > > > > > > > > > 2010-08-26 10:30:54,157 DEBUG [main] > > > > > > > org.apache.ibatis.io.ResolverUtil > > > > > > > > > > - Reader entry: BooleanToYorN.class - 1613 > > > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > > > org.apache.ibatis.io.ResolverUtil - Reader entry: > > > > > YorNToBoolean.class > > > > > > > > > > - 1623 > > > > > > > > > > 2010-08-26 10:30:54,167 DEBUG [main] > > > > > > > > > > org.apache.ibatis.io.ResolverUtil - Found class file: > > > > > > > com/myplace/orm/ > > > > > > > > > > mybatis/typehandlers/BooleanToYorN.class - 1623 > > ... > > read more » |
| Powered by Nabble | Edit this page |
