You wrote here <result property="dynamicProperty"
select="RamBabuExtension"/> : “*/_dynamicProperty_/*”.
But in your class User you have property */_properties_/* not
*/_dynamicProperty_/*
Property name in your configuration and in your class should be the same.
Best,
Aram.
------------------------------------------------------------------------
*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 27, 2006 5:34 PM
*To:* [email protected]
*Subject:* RE: Need help---Mapping of Complex properties
**what is wrong with this ?. The followign code is throwing null
pointer exception.**
<resultMap id="userMapForStaticAndDynamicRamBabu" class="user">
<result property="userid" column="USR_ID"/>
<result property="role" column="ROLE_ID"/>
<result property="description" column="DESCRIPTION"/>
<result property="dynamicProperty" select="RamBabuExtension"/>
</resultMap>
<resultMap id="userExtensionMapForStaticAndDynamicRamBabu"
class="dynamicProperty">
<result property="propertyname" column="PROPERTY_NAME"/>
<result property="propertyvalue" column="PROPERTY_VALUE"/>
</resultMap>
<statement id="RamBabu" resultClass="user"
resultMap="userMapForStaticAndDynamicRamBabu">
select * from USR_BASIC_INFO
</statement>
<statement id="RamBabuExtension"
resultMap="userExtensionMapForStaticAndDynamicRamBabu">
select * from USR_EXTENSION_INFO
</statement>
**Thanks a lot for your help.**
=============================
Rambabu Piridi.
Software Engineer,
Wipro Technologies,
Madhapur,
Hyderabad.
e-Mail : [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Mobile: 99491 83303.
==============================
------------------------------------------------------------------------
*From:* Mkhitaryan, Aram [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 27, 2006 5:58 PM
*To:* [email protected]
*Subject:* RE: Need help---Mapping of Complex properties
Now it is clear.
You have to write a select statement which will return all property
names and values.
You have to define a new result map which will map result from first
select to your UserProperties class.
You have to change result map for user select and for property
properties you should specify only attribute
select=”result-map-name-of-userproperties”.
And after enabling lazy loading from settings tag,
lazyLoadingEnabled=”true” attribute, everything should work properly.
I hope I describe clear enough so that you can configure perfectly.
Best,
Aram
------------------------------------------------------------------------
*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 27, 2006 5:09 PM
*To:* [email protected]
*Subject:* RE: Need help---Mapping of Complex properties
The scenario is like this.
User table: user Id, role, description
User Properties info: user Id, property name, property value.
For one user there can be multiple user properties like this.
User table:
user Id, role, description
xyz,1,jfdjfjl
abc,2,dljldjf
and
User Properties info
user Id, property name, property value
xyz,city,tokyo
xyz,phone,65809877
xyz,desg,manager
Here one user can contain multiple user properties.
Now tell me the query how to map.
there are my java bean classes.
public class User
{
String userId;
int role;
String description;
List<UserProperties> properties; // This stores the list of user
properties objects.
}
public class UserProperties
{
String userId;
String propertyName;
String propertyValue;
}
Is there wrong with my bean classes ?. If not please suggest the
query how to write in Ibatis for lazy loading.
Thanks n Regards,
=============================
Rambabu Piridi.
Software Engineer,
Wipro Technologies,
Madhapur,
Hyderabad.
e-Mail : [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Mobile: 99491 83303.
==============================
------------------------------------------------------------------------
*From:* Mkhitaryan, Aram [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 27, 2006 5:28 PM
*To:* [email protected]
*Subject:* RE: Need help---Mapping of Complex properties
First of all, try using JavaBeans, which means use bean object with
public getters and setters and make properties private.
For your question I have no answer since I have never met a sample
mapping for these kinds of mappings.
IBatis mapping uses java property name and column name (or index).
If these names are generic (depends on sql statement result) I think
it is not possible to configure mapping for this.
Best,
Aram
------------------------------------------------------------------------
*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 27, 2006 4:24 PM
*To:* [email protected]
*Subject:* RE: Need help---Mapping of Complex properties
Hi Mkhitaryan,
I have a bean class User.java
public class User
{
String id;
String name;
List propList;
}
I have two tables to map the user object
The first table will store the id and name of the user
id name
--- --------
and the second table is used to store the List of properties of the User.
The structure of the second table is
id propName propVal
---- -------------- ------------
Here id is the foeign key from the First table. There can be any
number of properties can exists for a single user.
can you please provide me the Ibatis mapping for this query using the
lazy initalization.
Thanks n Regards,
=============================
Rambabu Piridi.
------------------------------------------------------------------------
*From:* Mkhitaryan, Aram [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 27, 2006 4:36 PM
*To:* [email protected]
*Subject:* RE: Need help---Mapping of Complex properties
Value from this (PRD_CAT_ID) column will be used in the lazy statement
(getCategory).
------------------------------------------------------------------------
*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
*Sent:* Thursday, July 27, 2006 4:03 PM
*To:* [email protected]
*Subject:* Need help---Mapping of Complex properties
I am using this(This is mentioned in the Ibatis doc) to load the data.
*<resultMap id=”get-product-result” class=”com.ibatis.example.Product”>*
*<result property=”id” column=”PRD_ID”/>*
*<result property=”description” column=”PRD_DESCRIPTION”/>*
*<result property=”category” column=”**/PRD_CAT_ID/**”
select=”getCategory”/>*
*</resultMap>*
*<resultMap id=”get-category-result” class=”com.ibatis.example.Category”>*
*<result property=”id” column=”CAT_ID”/>*
*<result property=”description” column=”CAT_DESCRIPTION”/>*
*</resultMap>*
*<statement id=”getProduct” parameterClass=”int”
resultMap=”get-product-result”>*
*select * from PRODUCT where PRD_ID = #value#*
*</statement>*
*<statement id=”getCategory” parameterClass=”int”
resultMap=”get-category-result”>*
*select * from CATEGORY where **/CAT_ID /**= #value#*
*</statement>*
I have similar requirement to do lazy initalization. what is the
column //PRD_CAT_ID in this ?.//
Thanks n Regards,
=============================
Rambabu Piridi.
Software Engineer,
Wipro Technologies,
Madhapur,
Hyderabad.
e-Mail : [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Mobile: 99491 83303.
==============================
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
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
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
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