Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] Unset value/Update query
[Texo] Unset value/Update query [message #1200807] Thu, 21 November 2013 12:22 Go to next message
Bastian Wagenfeld is currently offline Bastian WagenfeldFriend
Messages: 183
Registered: January 2013
Senior Member
Hi Martin,

I've got a problem while unsetting a value. I want to set a double value (in EMF EDoubleObject, in DB double) to null. This works as long as I don't save the resource. Then the value gets reverted to the originally set value.
To avoid this, I created an update query on the resource to set the attribute null. But I got this exception:

java.lang.IllegalStateException: You cannot call getResultList() on this query.  It is the incorrect query type.


Of course, this makes sense. Is there any possibility to unset this value, either by unsetting it directly or by executing a query?

Best regards
Bastian
Re: [Texo] Unset value/Update query [message #1200978 is a reply to message #1200807] Thu, 21 November 2013 14:08 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Bastian,
Is the value set back to the original value by Texo on the server side or by EMF on the client side?
There is special EMF behavior that if you set an efeature to null it will return its default value when doing eGet
(which Texo does). So then the default value gets saved on the server. It should work fine as you have EDoubleObject
which should support nulls, but still, can you check?

One other thing which can happen is that Texo on the client side thinks that the value is not set and does not send
anything to the server. So the json send to the server does not contain the changed efeature. Can you check that?

gr. Martin

On 11/21/2013 01:22 PM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> I've got a problem while unsetting a value. I want to set a double value (in EMF EDoubleObject, in DB double) to null.
> This works as long as I don't save the resource. Then the value gets reverted to the originally set value.
> To avoid this, I created an update query on the resource to set the attribute null. But I got this exception:
>
> java.lang.IllegalStateException: You cannot call getResultList() on this query. It is the incorrect query type.
>
> Of course, this makes sense. Is there any possibility to unset this value, either by unsetting it directly or by
> executing a query?
>
> Best regards
> Bastian


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Unset value/Update query [message #1202488 is a reply to message #1200978] Fri, 22 November 2013 06:57 Go to previous messageGo to next message
Bastian Wagenfeld is currently offline Bastian WagenfeldFriend
Messages: 183
Registered: January 2013
Senior Member
Hi Martin,

it is almost like you supposed at last: The changed object is added to the "eObjectsToUpdate" list. At this place the attribute is null. But the json-String on the server side does not even contain the attribute, neither the attribute nor its value (null).

Best regards
Bastian
Re: [Texo] Unset value/Update query [message #1202555 is a reply to message #1202488] Fri, 22 November 2013 07:42 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Bastian,
Ok, but looking at the code it should do it, can you debug into the BaseModelJSONConverter in the
convertSingleEAttribute method. There the value is retrieved from the EMF object and put in the jsonobject.

Does it get there in your case for this eattribute?

gr. Martin

On 11/22/2013 07:57 AM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> it is almost like you supposed at last: The changed object is added to the "eObjectsToUpdate" list. At this place the
> attribute is null. But the json-String on the server side does not even contain the attribute, neither the attribute nor
> its value (null).
>
> Best regards
> Bastian


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Unset value/Update query [message #1202660 is a reply to message #1202555] Fri, 22 November 2013 08:53 Go to previous messageGo to next message
Bastian Wagenfeld is currently offline Bastian WagenfeldFriend
Messages: 183
Registered: January 2013
Senior Member
Hi,

the value is null and the propName is set correctly. The toJSON method of the JSONValueConverter returns null since none of the conditions is true. So the put method of the JSONObject is invoked with the correct key and null. The JSONObject code looks like that:
 public JSONObject put(String key, Object value) throws JSONException {
        if (key == null) {
            throw new NullPointerException("Null key.");
        }
        if (value != null) {
            testValidity(value);
            this.map.put(key, value);
        } else {
            this.remove(key);
        }
        return this;
    }


The value is null, so this.remove(key) is called.

Is there a possibility to avoid this?

Bastian
Re: [Texo] Unset value/Update query [message #1202710 is a reply to message #1202660] Fri, 22 November 2013 09:24 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ha, yes I think so, there is a JSONObject.NULL which I guess I can use.

Will try that.

gr. Martin

On 11/22/2013 09:53 AM, Bastian Wagenfeld wrote:
> Hi,
>
> the value is null and the propName is set correctly. The toJSON method of the JSONValueConverter returns null since none
> of the conditions is true. So the put method of the JSONObject is invoked with the correct key and null. The JSONObject
> code looks like that:
> public JSONObject put(String key, Object value) throws JSONException {
> if (key == null) {
> throw new NullPointerException("Null key.");
> }
> if (value != null) {
> testValidity(value);
> this.map.put(key, value);
> } else {
> this.remove(key);
> }
> return this;
> }
>
> The value is null, so this.remove(key) is called.
> Is there a possibility to avoid this?
>
> Bastian


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Unset value/Update query [message #1205611 is a reply to message #1202710] Sat, 23 November 2013 18:19 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Bastian,
I published a new build which should solve this.

gr. Martin

On 11/22/2013 10:24 AM, Martin Taal wrote:
> Ha, yes I think so, there is a JSONObject.NULL which I guess I can use.
>
> Will try that.
>
> gr. Martin
>
> On 11/22/2013 09:53 AM, Bastian Wagenfeld wrote:
>> Hi,
>>
>> the value is null and the propName is set correctly. The toJSON method of the JSONValueConverter returns null since none
>> of the conditions is true. So the put method of the JSONObject is invoked with the correct key and null. The JSONObject
>> code looks like that:
>> public JSONObject put(String key, Object value) throws JSONException {
>> if (key == null) {
>> throw new NullPointerException("Null key.");
>> }
>> if (value != null) {
>> testValidity(value);
>> this.map.put(key, value);
>> } else {
>> this.remove(key);
>> }
>> return this;
>> }
>>
>> The value is null, so this.remove(key) is called.
>> Is there a possibility to avoid this?
>>
>> Bastian
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Unset value/Update query [message #1209199 is a reply to message #1205611] Mon, 25 November 2013 11:40 Go to previous message
Bastian Wagenfeld is currently offline Bastian WagenfeldFriend
Messages: 183
Registered: January 2013
Senior Member
Hi Martin,

that fixed it. Thank you!

Bastian
Previous Topic:EMFStore stand-alone client api
Next Topic:[CDO] [Teneo] Default enum value persisted as NULL
Goto Forum:
  


Current Time: Wed Mar 03 09:34:42 GMT 2021

Powered by FUDForum. Page generated in 0.02344 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top