ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Poitras Christian" <Christian.Poit...@ircm.qc.ca>
Subject RE: Complex properties on insert
Date Thu, 02 Nov 2006 15:37:19 GMT
Yes.

To access complex properties, it is as simple as writing property access
for BeanUtils.
Like this :
<insert id="insertAdress" parameterClass="Address">
INSERT INTO Address(id, countryId)
VALUES (#id#, #country.id#)
</insert>

-----Original Message-----
From: Carlos Cajina [mailto:cecajina@hotmail.com] 
Sent: Wednesday, 01 November 2006 18:02
To: user-java@ibatis.apache.org
Subject: Re: Complex properties on insert

Hi Landry,

>From what I understand, you'll have to do the inserts one by one: first
the parent object and then its children...

Am I right guys?

Regards,
______________________________
Carlos
----- Original Message -----
From: "Landry Soules" <landry.p.soules@gmail.com>
To: <user-java@ibatis.apache.org>
Sent: Wednesday, November 01, 2006 4:19 PM
Subject: Complex properties on insert


> Hello,
>
> I'm a newbie and couldn't find a single example of how to manage
complex 
> properties on insert ?
>
> Heres is what i try to do :
>
> I have 2 classes : Address and Country.
> In the relation, of course one address has one country.
>
> Country is a stand-alone class, while Address has a property  of type 
> Country, something like this :
>
> public class Address ....
> private Country country ......
>
> In the mapping :
>
> <resultMap class="com.myhome.Address"
id="abatorgenerated_AddressResult">
>
> <result column="id" jdbcType="INTEGER" property="id"/>
>    <result column="add1" jdbcType="VARCHAR" property="add1"/>
>    <result column="add2" jdbcType="VARCHAR" property="add2"/>
>    <result column="city" jdbcType="VARCHAR" property="city"/>
>    <result column="zip_code" jdbcType="VARCHAR" property="zipCode"/>
>    <result column="state" jdbcType="INTEGER" property="state"/>
>    <result column="country" property="country" 
> select="address.getCountry"/>
>   </resultMap>
>  <resultMap id="country-result" class="com.seenxl.model.Country">
>  <result column="id" jdbcType="CHAR" property="id"/>
>    <result column="iso3" jdbcType="CHAR" property="iso3"/>
>    <result column="name" jdbcType="CHAR" property="name"/>
>    <result column="num_code" jdbcType="SMALLINT" property="numCode"/>
>    <result column="printable_name" jdbcType="CHAR" 
> property="printableName"/>
> </resultMap>
>
>
>
>
> I have no problem to select an address, but i can't make an insert
work.
> I there a trick i have skipped  or can you point me to a sample code, 
> thank you.
>
> 



Mime
View raw message