Any ideas anyone?

On Monday, November 14, 2016 at 1:25:05 PM UTC-8, Borov wrote:
>
> I'm trying run a transaction which will perform few operations using SQL. 
> First it will create a new document, then it will update a status of 
> another document and third, it will create an edge between an existing 
> document and the newly created. I tried to use a transaction and even 
> nested transactions, but to no avail. Mainly the problem is that when I 
> create a document with an SQL, it returns a temporary RID. It seems to me 
> that Orient doesn't like to use temp document RID to create an edge.
>
> I'm using the latest 2.2.12 version. Here is a simple version of the code:
>
> ODatabaseDocumentTx db = DbPool.getConnection();
> String existingRid = "#111:1";
>
> try {
>     db.begin();
>
>     // create transaction record
>     ODocument doc = new ODocument("TransactionDirectPost");
>     ODocument transaction = doc.save();
>     String transactionRid = transaction.getIdentity().toString();
>
>     // change data state to sold
>     String sql = "update ? set metaInternal.dataState = ?";
>     db.command(new OCommandSQL(sql)).execute(new ORecordId(existingRid), 
> "SOLD");
>
>     // create an edge
>     sql = "create edge SentDirectPost from ? to ?";
>     db.command(new OCommandSQL(sql)).execute(new ORecordId(existingRid), 
> new ORecordId(transactionRid));
>
>     db.commit();
> } catch (Exception e) {
>     db.rollback();
> } finally {
>     db.close();
> }
>
> Error I'm getting:
>
> Cannot read record #-1:-2 since the position is invalid in database 
> 'Customers'
>
> The error is thrown at the edge creation time.
>
> It seems logical to perform SQL operations in a single transaction. Is 
> this a completely incorrect way of doing such operations? If so, what is 
> the right or best way to do it? 
>
> Thanks.
>
>

-- 

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