ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mkhitaryan, Aram" <Aram.Mkhitar...@lycos-europe.com>
Subject RE: Need help---Mapping of Complex properties
Date Fri, 28 Jul 2006 09:34:58 GMT
Try to change statement tag to select.

And try to remove generic declaration from your User class (maybe there are problems with
generic support?).

Just specify properties as array or simple List.

Also try different implementations ArrayList, … .

 

I have never used this kind of queries. But I really need to do that for next week.

Maybe I can reply to this question after my own implementation is successful?

 

Best,

Aram

 

________________________________

From: rambabu.piridi@wipro.com [mailto:rambabu.piridi@wipro.com] 
Sent: Friday, July 28, 2006 1:25 PM
To: user-java@ibatis.apache.org
Subject: RE: Need help---Mapping of Complex properties

 

Hi Aram,

Thank you for your reply. I found the exact problem. Can you please help me now.?

 

The following query is working if the user is having exactly one user properties record.

Here the User is master table and Properties is detail table.

 

<resultMap id="userMapForStaticAndDynamicRamBabu" class="user">

<result property="userid" column="USR_ID"/>

<result property="role" column="ROLE_ID"/> 

<result property="description" column="DESCRIPTION"/> 

<result property="properties" column="USR_ID" select="RamBabuExtension" />

</resultMap>

<resultMap id="userExtensionMapForStaticAndDynamicRamBabu" class="iBatisDynamicProperty">

<result property="userid" column="USR_ID"/>

<result property="propertyname" column="PROPERTY_NAME"/> 

<result property="propertyvalue" column="PROPERTY_VALUE"/> 

</resultMap>

<statement id="RamBabu" resultMap="userMapForStaticAndDynamicRamBabu"> 

     select * from USR_BASIC_INFO

</statement> 

<statement id="RamBabuExtension" resultMap="userExtensionMapForStaticAndDynamicRamBabu">


   select * from USR_EXTENSION_INFO where USR_ID=#userid#

</statement> 

If the second select query(select * from USR_EXTENSION_INFO where USR_ID=#userid#) returns
multiple results then 

it is throwing the following error.

Check the User.userMapForStaticAndDynamicRamBabu. 

--- Check the result mapping for the 'properties' property. 

--- Cause: java.sql.SQLException: Error: executeQueryForObject returned too many results.

we are getting this error because the second query is returning multiple results. If only
one record per user is there then there

is no issue. So can you please look into this.

 

So some where i have to change to List, this is i am not getting where to change.

Any way thanks a lot Aram.

 

I have get and set methods for the properties attribute. The paramater for the set method
is iBatisDynamicProperty

which is specified in the resultMap.

 

regards,

Rambabu

 

________________________________

From: Mkhitaryan, Aram [mailto:Aram.Mkhitaryan@lycos-europe.com] 
Sent: Friday, July 28, 2006 9:50 AM
To: user-java@ibatis.apache.org
Subject: RE: Need help---Mapping of Complex properties

<result property="properties" column="USR_ID" select="RamBabuExtension" />

 

You missed also column attribute. 

Also use USR_ID=#value# instead of USR_ID=#usr_id#

Add this and try again.

 

Best,

Aram

 

________________________________

From: rambabu.piridi@wipro.com [mailto:rambabu.piridi@wipro.com] 
Sent: Friday, July 28, 2006 9:07 AM
To: user-java@ibatis.apache.org
Subject: RE: Need help---Mapping of Complex properties

 

 

 

<resultMap id="userMapForStaticAndDynamicRamBabu" class="user" groupBy="userid">

<result property="userid" column="USR_ID"/>

<result property="username" column="USR_NAME"/> 

<result property="role" column="ROLE_ID"/> 

<result property="description" column="DESCRIPTION"/> 

<result property="properties" select="RamBabuExtension" />

</resultMap>

<resultMap id="userExtensionMapForStaticAndDynamicRamBabu" class="UserProperty">

<result property="propertyname" column="PROPERTY_NAME"/> 

<result property="propertyvalue" column="PROPERTY_VALUE"/> 

</resultMap>

<statement id="RamBabu" resultMap="userMapForStaticAndDynamicRamBabu"> 

select * from USR_BASIC_INFO

</statement> 

<statement id="RamBabuExtension" resultMap="userExtensionMapForStaticAndDynamicRamBabu">


select * from USR_EXTENSION_INFO where USR_ID=#usr_id#

</statement> 

 

 

Thanks n Regards,

==============

Rambabu Piridi.

 


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
	
Mime
View raw message