ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ali Zaid <allo...@gmail.com>
Subject Again the issue of the HashMap
Date Fri, 22 Jul 2005 21:45:21 GMT
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