You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Phillip S <to...@hotmail.com> on 2007/08/27 23:07:41 UTC

Struct

Team,
 
I am having some problems with struct and searched the archives.  I found an article indicating IBATIS does not support struct.  Can anyone else please confirm that?
 
Thanks
_________________________________________________________________
See what you’re getting into…before you go there
http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_preview_0507

Re: Struct

Posted by Nicholas Piasecki <ni...@piasecki.name>.
Phillip S wrote:
>   Team,
>  
> I am having some problems with struct and searched the archives.  I 
> found an article indicating IBATIS does not support struct.  Can anyone 
> else please confirm that?
>  
> Thanks
> 
> See what you’re getting into…before you go there See it! 
> <http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_preview_0507>

I ran into that once. No, you can't use structs. You also can't use 
public members, as I seem to remember being burnt by that one too. 
(Happened to me when I tried to use ASP.NET's Pair class or something 
like that.)

Use classes with properties that have getters and setters (although the 
property, getter, and setter can be private).

If you need something small just for passing into a query, try 
parameterClass="map" and pass in a Dictionary object. E.g.,

Dictionary<string, object> param = new Dictionary<string, object>();
param.Add("DaLastName", "Piasecki");
param.Add("DaFirstName", "Nicholas");

LocalSqlMap.QueryForObject("SomeSelectStatement", param);

<select id="SomeSelectStatement" parameterClass="map" resultMap="UserMap">
    SELECT * FROM people where LastName = #DaLastName# AND FirstName = 
#DaFirstName#
</select>

Hope that helps, and hope it isn't misguided in any way =)

V/R,
Nicholas Piasecki