<resultMap id="userMap" class="user">
<result property="userid" column="USR_ID"/>
<result property="password" column="USR_PWD"/>
<result property="username" column="USR_NAME"/>
<result property="role" column="ROLE_ID"/>
<result property="code" column="USR_CODE"/>
<result property="email" column="EMAIL_ID"/>
<result property="phoneno" column="PHONE_NUMBER"/>
<result property="description" column="DESCRIPTION"/>
<result property="dynamicProperties" resultMap="User.userMap1"/>
</resultMap>
<resultMap id="userMap1" class="dynamicPropertey">
<result property="propertyName" column="PROPERTY_NAME"/>
<result property="propertyValue" column="PROPERTY_VALUE"/>
</resultMap>
<select id="select4" resultMap="userMap">
select * from USR_BASIC_INFO, USR_EXTENSION_INFO where USR_BASIC_INFO.USR_ID=USR_EXTENSION_INFO.USR_ID;
</select>
My test
class
List list1 = (List)
sqlMap.queryForList("select4",null);
Iterator iterator =
list1.iterator();
System.out.println(list1.size());
while(iterator.hasNext())
{
System.out.println("dfkADFJKs"+iterator.next());
User
user =(User )iterator.next(); // I am
getting exception
}
My bean class:
package com.epson.usermanagement;
import
java.util.ArrayList;
import java.util.Iterator;
/**
* This class contains all
the properties of the user and also contains the methods
* to set and
get the values of particular property of the user.
*
*/
public class User
{
//private DynamicProperty dynamicPropertey;
private ArrayList dynamicProperties = new
ArrayList();
public
User(){
}
/**
* The
variable holds value of the property UserId
*
*/
private String userid;
/**
* The variable
holds value of the property PassWord
*
*/
private
String password;
/**
* The variable
holds value of the property UserName
*
*/
private
String username;
/**
* The variable holds value of
the property Email
*
*/
private String
email;
/**
* The variable
holds value of the property Code
*
*/
private
String code;
/**
* The variable
holds value of the property Role
*
*/
private int
role;
/**
* The variable
holds value of the property PhoneNo
*
*/
private
String phoneno;
/**
* The variable
holds value of the property Description
*
*/
private String description;
/**
* Returns the
code for particular user
*/
public String getCode()
{
return code;
}
/**
* sets
the value to code property of the UserProperty Object
*/
public void setCode(String Code) {
this.code =
Code;
}
/**
* Returns the
Description for particular user
*/
public String
getDescription() {
return description;
}
/**
* sets the value to
description property of the UserProperty Object
*/
public
void setDescription(String description) {
this.description =
description;
}
/**
* Returns the
Email address for particular user
*/
public String getEmail()
{
return email;
}
/**
* sets the value to
email property of the UserProperty Object
*/
public void
setEmail(String email) {
this.email =
email;
}
/**
* Returns the
Password for particular user
*/
public String getPassword()
{
return password;
}
/**
* sets the value to
password property of the UserProperty Object
*/
public void
setPassword(String password) {
this.password =
password;
}
/**
* Returns the
username for particular user
*/
public String getUsername()
{
return username;
}
/**
* sets the value to
username property of the UserProperty Object
*/
public void
setUsername(String username) {
this.username =
username;
}
/**
* Returns the
PhoneNo for particular user
*/
public String getPhoneno()
{
return phoneno;
}
/**
* sets the value to
phoneno property of the UserProperty Object
*/
public void
setPhoneno(String phoneno) {
this.phoneno =
phoneno;
}
/**
* Returns the
Role for particular user
*/
public int
getRole()
{
return role;
}
/**
* sets the value to
role property of the UserProperty Object
*/
public void
setRole(int role) {
this.role = role;
}
/**
* Returns the
UserId for particular user
*/
public String getUserid()
{
return userid;
}
/**
* sets the
value to code property of the UserProperty Object
*/
public
void setUserid(String userid) {
this.userid =
userid;
}
/**
* Returns the dynamic properties of
the UMC user.
*/
public ArrayList
getDynamicProperties()
{
return
dynamicProperties;
}
/**
*
Sets the dynamic properties of the UMC user.
*/
public void
setDynamicProperties(ArrayList
dynamicProperties)
{
System.out.println("I am
testting");
if(dynamicProperties == null)
return;
System.out.println("I am testting"
+ dynamicProperties.size());
Iterator i =
dynamicProperties.iterator();
System.out.println("I am testting"
+
dynamicProperties.size());
while(i.hasNext())
{
String
key = (String) i.next();
String value = (String)
i.next();
}
}
/**
* @param
dynamicPropertey The dynamicPropertey to set.
public void
setDynamicPropertey(DynamicProperty dynamicPropertey)
{
System.out.println("I am
setting");
listDynamicProperties.add(dynamicPropertey);
this.dynamicPropertey
= dynamicPropertey;
}
public DynamicProperty
getDynamicPropertey() {
return
dynamicPropertey;
}
*/
}
package
com.epson.usermanagement;
public class DynamicProperty
{
private String propertyName;
private String
propertyValue;
private String
userId;
/*
* name and value should not
be null.
* If null throw Exception.
*/
public
DynamicProperty()
{
}
public String
getPropertyName() {
return
propertyName;
}
public void
setPropertyName(String propertyName)
{
this.propertyName =
propertyName;
}
public String
getPropertyValue() {
return
propertyValue;
}
public void
setPropertyValue(String propertyValue)
{
this.propertyValue =
propertyValue;
}
public
String getUserId() {
return
userId;
}
}
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com |
