You're right: if you deploy your logic in the server, your function will be
in the TX scope. I've just created your function on an empty database and
works:

[
    {
        "@type": "d",
        "@rid": "#19:0",
        "@version": 1,
        "@class": "UserProfile",
        "name": "test10-5"
    }
]

But in that code there is no begin/commit, so everything is not tx. When
you see "in transaction", what do you mean?

So I've changed the function to be like:

var db = orient.getDatabase();
db.begin();
db.save({
  "@class": "UserProfile",
  name : "test10-5"});

var userProfile = db.query('SELECT FROM UserProfile WHERE name =
"test10-5"');
db.commit();
return userProfile;

And still works:

[
    {
        "@type": "d",
        "@rid": "#19:0",
        "@version": 1,
        "@class": "UserProfile",
        "name": "test10-5"
    },
    {
        "@type": "d",
        "@rid": "#19:1",
        "@version": 1,
        "@class": "UserProfile",
        "name": "test10-5"
    }
]


Best Regards,

Luca Garulli
Founder & CEO
OrientDB <http://orientdb.com/>


On 24 May 2016 at 20:56, Emrul Islam <[email protected]> wrote:

> Actually, unless I am mistaken you are saving then querying within the
> *same* server-side function.  In this instance, it *should* work I think.
>
> Will let the OrientDB guys comment.
>
>
> On Monday, May 23, 2016 at 5:11:03 PM UTC+1, Jean-Sebastien Lemay wrote:
>>
>> I now realize that what I'm looking for is serializable isolation, which
>> OrientDB does not offer. I was not aware of that. OK, that means a lot of
>> problems for me. I thought I could achieve serializable level of isolation
>> if I put all my logic within server-side functions.
>>
>> Cheers,
>> Jean
>>
>>
>> On Monday, May 23, 2016 at 11:55:35 PM UTC+8, Jean-Sebastien Lemay wrote:
>>>
>>> Yes, I am using remote, and I need to figure out a way to be able to
>>> read my own modifications within the same transaction.
>>>
>>> How would I update my function to be able to access the data, including
>>> modifications and new entities, within the current transaction?
>>>
>>>
>>> Cheers,
>>> Jean
>>>
>>>
>>> On Monday, May 23, 2016 at 11:33:45 PM UTC+8, l.garulli wrote:
>>>>
>>>> Are you connected with remote ? In this case the server-side function
>>>> is out of the transaction that is on the client only until the commit().
>>>> Could it be the reason?
>>>>
>>>> Best Regards,
>>>>
>>>> Luca Garulli
>>>> Founder & CEO
>>>> OrientDB <http://orientdb.com/>
>>>>
>>>>
>>>> On 23 May 2016 at 15:57, Jean-Sebastien Lemay <[email protected]>
>>>> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> Yes, it works within the UI, but if you create a transaction with the
>>>>> Java API and execute the function it is unable to retrieve the record.
>>>>>
>>>>> See my Java code:
>>>>> *OrientGraph db = test.graphFactory.getTx();*
>>>>> *OIdentifiable[] retValue1 = (OIdentifiable[])db.getRawGraph()*
>>>>> * .getMetadata()*
>>>>> * .getFunctionLibrary()*
>>>>> * .getFunction("testCreate")*
>>>>> * .execute();*
>>>>>
>>>>> *for (OIdentifiable oId : retValue1) {*
>>>>> * System.out.println(String.format(*
>>>>> * "#%s:%s",*
>>>>> * oId.getIdentity().getClusterId(),*
>>>>> * oId.getIdentity().getClusterPosition()));*
>>>>> *}   *
>>>>>
>>>>> *db.commit();*
>>>>>
>>>>> In the above example, my loop doesn't print anything, implying that my
>>>>> return array is empty. How come?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Monday, May 23, 2016 at 9:41:32 PM UTC+8, [email protected]
>>>>> wrote:
>>>>>>
>>>>>> Hi Jean-Sebastien,
>>>>>>
>>>>>> I tried your script with version 2.2 and setting the language as
>>>>>> javascrpit it works fine for me:
>>>>>>
>>>>>>
>>>>>> <https://lh3.googleusercontent.com/-kP6UT0t2epo/V0MIYJD3xzI/AAAAAAAAADQ/POikhaHzrz40xUQODiRC26YK_MvkCsKtQCLcB/s1600/script.png>
>>>>>>
>>>>>>
>>>>>>
>>>>>> <https://lh3.googleusercontent.com/-zIcSm3YdquU/V0MIb71d-II/AAAAAAAAADU/YX2AOSiiBcA-ndUO7kkyOe71T20i_lTUgCLcB/s1600/ok.png>
>>>>>>
>>>>>>
>>>>>> Hope it helps.
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Michela
>>>>>>
>>>>>> --
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "OrientDB" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OrientDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to