ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: Again the issue of the HashMap
Date Wed, 27 Jul 2005 11:49:06 GMT
If there is not a JIRA issue for this, please add one.

I think it could be addressed with an added attribute for the result 
element. 

Something like queryMethod="list|map|object" would do. Then we would need a 
way to know which properties were to be used for key/value in the results.

Another option for you would be to create a type handler to do this. I think 
you could make it generic enough to be reusable.

Larry


On 7/22/05, Ali Zaid <allochi@gmail.com> wrote:
> 
> Hi All;
> 
> This is mostly to iBatis developers, but I appreciate the help from
> anyone. The thing is that I searched the Mailing List for a solution,
> and I found out that there isn't one, So I hope that this is addressed
> for the future or that there is a solution and I'm not aware about.
> 
> In my case I have a class called user
> 
> public class User {
> 
> private String userName;
> private String fullName;
> private HashMap permissions;
> 
> // ---------- Getters & Setters ----------
> }
> 
> <resultMap id="rm_userWithPermissions" class="com.allochi.test.User">
> <result property="userName" column="userName" />
> <result property="fullName" column="fullName" />
> <result property="permissions" column="userID" select="getUserPermissions" 
> />
> </resultMap>
> 
> <select id="getAllUsersWithPermissions" 
> resultMap="rm_userWithPermissions">
> SELECT *
> FROM _user
> </select>
> 
> <select id="getUserPermissions" parameterClass="int"
> resultClass="java.util.HashMap">
> SELECT dbo._permissionKey.permissionKey as pKey,
> dbo._permissionKeyVlaueList.permissionValue as pValue FROM dbo._user INNER
> JOIN dbo._userPermission ON dbo._user.userID =
> dbo._userPermission.userID INNER JOIN dbo._permissionKey ON
> dbo._userPermission.permissionKeyID =
> dbo._permissionKey.permissionKeyID INNER JOIN
> dbo._permissionKeyVlaueList ON
> dbo._userPermission.permissionValueID =
> dbo._permissionKeyVlaueList.permissionValueID WHERE
> (dbo._user.userID = #value#)
> </select>
> 
> The result of this is...
> 
> Administrator
> pKey : canDoAll
> pValue : true
> 
> now what I intend to do is to have permissions loaded as (key,value) =
> (canDoAll,true), and check if somone can do something by saying...
> 
> if (user.getPermissions().get("canSave") == "YesButOnlyText") {
> // Save only text
> }
> 
> Now, I'm not seeking to change my logic, cause it was agreed on by my
> team and too late to go back, and I can overcome this by coding it in
> java code, but I though that I would find a way, a simple way to load
> simple map like this as a lookup HashMap. So, Please help.
> 
> I'm a big fan of iBatis, I actually reWrote several project of mine
> from hibernate to iBatis, iBatis saved me when Hibernate failed and
> almost got me fired.
> 
> I'm thinking too to write a plugin in eclipse for iBatis, just a
> simple thing, but this is not a promise :), actually I would love to
> know if someone is so I don't waist time :)
> 
> Thanks for the great work iBatis team, and can't wait for iBatis 3.0,
> Please hurry up.
> 
> --
> Regards, Ali
>

Mime
View raw message