how to use selectKey where property is an object‏

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how to use selectKey where property is an object‏

wekasalim
Hi guys,

I want to use selectKey to get the inserted id, however the property of the id on my class (Event) is actually an object as well. The name is Identifier and it has int property named Id. The following does not work:

  <insert id="InsertEvent" parameterClass="Event">
      INSERT INTO nxEvent
      (Title, Time)
      VALUES
      (#Title#, #Time#)
      <selectKey resultClass="int" type="post" property="Identifier.Id" >
        select @@IDENTITY as value
      </selectKey>
  </insert>

It says Event does not have Set member for 'Identifier.Id' Is there a way to do this?

Thanks,
Willy
Reply | Threaded
Open this post in threaded view
|

Re: how to use selectKey where property is an object‏

Michael McCurrey-3
What DB platform are you running on?


On Wed, May 19, 2010 at 4:15 PM, wekasalim <[hidden email]> wrote:

Hi guys,

I want to use selectKey to get the inserted id, however the property of the
id on my class (Event) is actually an object as well. The name is Identifier
and it has int property named Id. The following does not work:

 <insert id="InsertEvent" parameterClass="Event">
     INSERT INTO nxEvent
     (Title, Time)
     VALUES
     (#Title#, #Time#)
     <selectKey resultClass="int" type="post" property="Identifier.Id" >
       select @@IDENTITY as value
     </selectKey>
 </insert>

It says Event does not have Set member for 'Identifier.Id' Is there a way to
do this?

Thanks,
Willy
--
View this message in context: http://old.nabble.com/how-to-use-selectKey-where-property-is-an-object%E2%80%8F-tp28615389p28615389.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




--
Michael J. McCurrey
Read with me at http://www.mccurrey.com
http://chaoticmindramblings.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: how to use selectKey where property is an object‏

wekasalim
I'm using SQL Server 2008..

Is there a way of not using the selectKey but instead the whole insert is returning int like:

>  <insert id="InsertEvent" parameterClass="Event" resultClass="int">
>      INSERT INTO nxEvent
>      (Title, Time)
>      VALUES
>      (#Title#, #Time#)
>        select @@IDENTITY as value
>  </insert>

Because setting it on the object is not important for me anyway..

Thanks

Michael McCurrey-3 wrote
What DB platform are you running on?


On Wed, May 19, 2010 at 4:15 PM, wekasalim <wekasalim@hotmail.com> wrote:

>
> Hi guys,
>
> I want to use selectKey to get the inserted id, however the property of the
> id on my class (Event) is actually an object as well. The name is
> Identifier
> and it has int property named Id. The following does not work:
>
>  <insert id="InsertEvent" parameterClass="Event">
>      INSERT INTO nxEvent
>      (Title, Time)
>      VALUES
>      (#Title#, #Time#)
>      <selectKey resultClass="int" type="post" property="Identifier.Id" >
>        select @@IDENTITY as value
>      </selectKey>
>  </insert>
>
> It says Event does not have Set member for 'Identifier.Id' Is there a way
> to
> do this?
>
> Thanks,
> Willy
> --
> View this message in context:
> http://old.nabble.com/how-to-use-selectKey-where-property-is-an-object%E2%80%8F-tp28615389p28615389.html
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-cs-help@ibatis.apache.org
>
>


--
Michael J. McCurrey
Read with me at http://www.mccurrey.com
http://chaoticmindramblings.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: how to use selectKey where property is an object‏

Juan Pablo Araya
As far as I know you have two choices:

1. Set another property for Event class:

Public IdInserted { get { return Identifier.Id; } set { Identifier.Id
= value; }  }  -> null reference if Identifier is not instanced.

2. Create an insert procedure and pass the class for parameterMap,
setting the type @proced_Id as output and mapp it to Identifier.Id.

Greetings and sorry for my poor english!

2010/5/19 wekasalim <[hidden email]>:

>
> I'm using SQL Server 2008..
>
> Is there a way of not using the selectKey but instead the whole insert is
> returning int like:
>
>>  <insert id="InsertEvent" parameterClass="Event" resultClass="int">
>>      INSERT INTO nxEvent
>>      (Title, Time)
>>      VALUES
>>      (#Title#, #Time#)
>>        select @@IDENTITY as value
>>  </insert>
>
> Because setting it on the object is not important for me anyway..
>
> Thanks
>
>
> Michael McCurrey-3 wrote:
>>
>> What DB platform are you running on?
>>
>>
>> On Wed, May 19, 2010 at 4:15 PM, wekasalim <[hidden email]> wrote:
>>
>>>
>>> Hi guys,
>>>
>>> I want to use selectKey to get the inserted id, however the property of
>>> the
>>> id on my class (Event) is actually an object as well. The name is
>>> Identifier
>>> and it has int property named Id. The following does not work:
>>>
>>>  <insert id="InsertEvent" parameterClass="Event">
>>>      INSERT INTO nxEvent
>>>      (Title, Time)
>>>      VALUES
>>>      (#Title#, #Time#)
>>>      <selectKey resultClass="int" type="post" property="Identifier.Id" >
>>>        select @@IDENTITY as value
>>>      </selectKey>
>>>  </insert>
>>>
>>> It says Event does not have Set member for 'Identifier.Id' Is there a way
>>> to
>>> do this?
>>>
>>> Thanks,
>>> Willy
>>> --
>>> View this message in context:
>>> http://old.nabble.com/how-to-use-selectKey-where-property-is-an-object%E2%80%8F-tp28615389p28615389.html
>>> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>>
>> --
>> Michael J. McCurrey
>> Read with me at http://www.mccurrey.com
>> http://chaoticmindramblings.blogspot.com/
>>
>>
>
> --
> View this message in context: http://old.nabble.com/how-to-use-selectKey-where-property-is-an-object%E2%80%8F-tp28615389p28616859.html
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Juan Pablo Araya
787 76 034

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: how to use selectKey where property is an object‏

wekasalim
Hmm that's not a bad idea for workaround :) should resolve my problem.

Thanks!

Juan Pablo Araya wrote
As far as I know you have two choices:

1. Set another property for Event class:

Public IdInserted { get { return Identifier.Id; } set { Identifier.Id
= value; }  }  -> null reference if Identifier is not instanced.

2. Create an insert procedure and pass the class for parameterMap,
setting the type @proced_Id as output and mapp it to Identifier.Id.

Greetings and sorry for my poor english!

2010/5/19 wekasalim <wekasalim@hotmail.com>:
>
> I'm using SQL Server 2008..
>
> Is there a way of not using the selectKey but instead the whole insert is
> returning int like:
>
>>  <insert id="InsertEvent" parameterClass="Event" resultClass="int">
>>      INSERT INTO nxEvent
>>      (Title, Time)
>>      VALUES
>>      (#Title#, #Time#)
>>        select @@IDENTITY as value
>>  </insert>
>
> Because setting it on the object is not important for me anyway..
>
> Thanks
>
>
> Michael McCurrey-3 wrote:
>>
>> What DB platform are you running on?
>>
>>
>> On Wed, May 19, 2010 at 4:15 PM, wekasalim <wekasalim@hotmail.com> wrote:
>>
>>>
>>> Hi guys,
>>>
>>> I want to use selectKey to get the inserted id, however the property of
>>> the
>>> id on my class (Event) is actually an object as well. The name is
>>> Identifier
>>> and it has int property named Id. The following does not work:
>>>
>>>  <insert id="InsertEvent" parameterClass="Event">
>>>      INSERT INTO nxEvent
>>>      (Title, Time)
>>>      VALUES
>>>      (#Title#, #Time#)
>>>      <selectKey resultClass="int" type="post" property="Identifier.Id" >
>>>        select @@IDENTITY as value
>>>      </selectKey>
>>>  </insert>
>>>
>>> It says Event does not have Set member for 'Identifier.Id' Is there a way
>>> to
>>> do this?
>>>
>>> Thanks,
>>> Willy
>>> --
>>> View this message in context:
>>> http://old.nabble.com/how-to-use-selectKey-where-property-is-an-object%E2%80%8F-tp28615389p28615389.html
>>> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
>>> For additional commands, e-mail: user-cs-help@ibatis.apache.org
>>>
>>>
>>
>>
>> --
>> Michael J. McCurrey
>> Read with me at http://www.mccurrey.com
>> http://chaoticmindramblings.blogspot.com/
>>
>>
>
> --
> View this message in context: http://old.nabble.com/how-to-use-selectKey-where-property-is-an-object%E2%80%8F-tp28615389p28616859.html
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-cs-help@ibatis.apache.org
>
>



--
Juan Pablo Araya
787 76 034

---------------------------------------------------------------------
To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-cs-help@ibatis.apache.org