Odysseas,

Yes I'm aware of that. The thing is it requires an additional request to 
the DB (yes not much overhead but I don't like it), me writing a method 
looking for an identical record (except the ID) which will have to be very 
generic AND potential problems if someone by mistake adds a DB class which 
doesn't have to be unique, in such case I won't have any way of telling 
which record's ID should I retrieve as there could be multiple identical 
ones. In such case I would have to add some kind of a timestamp or my my 
own ID.

I was wondering if there's a way to retrieve the result of the commit (what 
the commit actually did, some kind of temp -> permanent ID mapping) or to 
reload the document we got back from save() so it updates it's ID 
automatically.

Mateusz

On Thursday, March 27, 2014 11:27:02 PM UTC+9, Odysseas wrote:
>
> Mateusz,
>
> After the commit the object will have a permanent ID assigned to it so if 
> you retrieve the identity of the saved object, you should get a permanent 
> record ID.
>
> Odysseas
>
> On Wednesday, March 26, 2014 11:16:43 AM UTC-4, Mateusz Dymczyk wrote:
>>
>> As mentioned in the wiki (
>> https://github.com/orientechnologies/orientdb/wiki/Transactions) while 
>> storing documents in the DB in a transaction they are assigned a temporary 
>> ID. Is there any way to get the permanent ID of that record after a commit? 
>> I read in one of the discussions that the commit() should return a mapping 
>> of changed IDs but I couldn't find is it how it actually works/how to use 
>> it.
>>
>> Let's say we have a sample code like in the wiki example:
>>
>> try{  db.begin(TXTYPE.OPTIMISTIC);
>>   ODocument saved = db.save(document);
>>   db.commit();  return saved;
>> } catch( Exception e ){  db.rollback();} finally{
>>   db.close();}
>>
>> Is there a way to store in "saved" the permanent ID instead of the 
>> temporary one before the return statement? A query for that permanent ID 
>> would be one way but I would really prefer to avoid having to do that kind 
>> of "tricks".
>>
>> Regards,
>> Mateusz
>>
>

-- 

--- 
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