Hi Jon,
You can create relationships in transaction, even if temporary, at commit
time OrientDB will take care to transform them in final and update
relationships. Take a look also to SQL Batch:

-
http://www.orientechnologies.com/docs/1.7.8/orientdb.wiki/Graph-Database-Tinkerpop.html#sql-batch
and
- http://www.orientechnologies.com/docs/1.7.8/orientdb.wiki/SQL-batch.html

Lvc@
ᐧ


On 23 August 2014 03:29, Jon Fields <[email protected]> wrote:

> It seems that the problem is mixing SQL commands with Document API calls.
> The following works with no problems:
>
> db = ODatabaseDocumentPool.global().acquire("remote:localhost/elasternity"
> , "admin", "admin");
>
> schema = db.getMetadata().getSchema()
> test = schema.createClass("Test");
> test.createProperty("name", OType.STRING)
> test.createProperty("children", OType.LINKLIST, test)
> schema.save()
> doc = new ODocument("Test")
> doc.field("field1", "value1")
> doc.save()
>
> I'd still be interested in hearing any comments about creating
> relationships in a transaction. It seems that since rids are not
> pre-allocated in a transaction, that creating a relationship will always
> require a separate transaction, correct? Or am I missing something. Thanks!
>
>
> On Friday, August 22, 2014 8:23:34 PM UTC-4, Jon Fields wrote:
>
>>
>> The following Groovy script:
>>
>> db = ODatabaseDocumentPool.global().acquire("remote:localhost/test",
>> "admin", "admin");
>> db.command(new OCommandSQL("create class Test")).execute();
>> // other schema related SQL commands to create properties and indexes
>> root = new ODocument("Test");
>> root.save();
>>
>>
>>
>> Throws this exception
>>
>>
>> Caught: com.orientechnologies.orient.core.exception.OStorageException:
>> Error in creation of new cluster 'Test' of type: PHYSICAL
>> com.orientechnologies.orient.core.exception.OStorageException: Error in
>> creation of new cluster 'Test' of type: PHYSICAL
>>     at com.orientechnologies.orient.core.storage.impl.local.paginated.
>> OLocalPaginatedStorage.addCluster(OLocalPaginatedStorage.java:516)
>>     at com.orientechnologies.orient.core.db.raw.ODatabaseRaw.addCluster(
>> ODatabaseRaw.java:425)
>>     at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.
>> addCluster(ODatabaseWrapperAbstract.java:205)
>>     at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.
>> addCluster(ODatabaseWrapperAbstract.java:205)
>>     at com.orientechnologies.orient.core.db.ODatabaseRecordWrapperA
>> bstract.addCluster(ODatabaseRecordWrapperAbstract.java:77)
>>     at com.orientechnologies.orient.server.network.protocol.binary.
>> ONetworkProtocolBinary.addCluster(ONetworkProtocolBinary.java:542)
>>     at com.orientechnologies.orient.server.network.protocol.binary.
>> ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:289)
>>     at com.orientechnologies.orient.server.network.protocol.binary.
>> OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.
>> java:169)
>>     at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.
>> java:45)
>> Caused by: com.orientechnologies.orient.core.exception.OConfigurationEx
>> ception: Cannot add segment 'test' because it is already registered in
>> database 'test'
>>     at com.orientechnologies.orient.core.storage.impl.local.paginated.
>> OLocalPaginatedStorage.registerCluster(OLocalPaginatedStorage.java:2180)
>>     at com.orientechnologies.orient.core.storage.impl.local.paginated.
>> OLocalPaginatedStorage.addClusterInternal(OLocalPaginatedStorage.java:
>> 2036)
>>     at com.orientechnologies.orient.core.storage.impl.local.paginated.
>> OLocalPaginatedStorage.doAddCluster(OLocalPaginatedStorage.java:2013)
>>     at com.orientechnologies.orient.core.storage.impl.local.paginated.
>> OLocalPaginatedStorage.addCluster(OLocalPaginatedStorage.java:513)
>>     ... 8 more
>>
>> However this (or the same using the console) has no problems:
>>
>> db = ODatabaseDocumentPool.global().acquire("remote:localhost/
>> elasternity", "admin", "admin");
>> db.command(new OCommandSQL("create class Test")).execute();
>> db.command(new OCommandSQL("insert into Test set name = ''")).execute();
>>
>> This is a part of a larger script that is first creating the schema for
>> the classes and then performing some initial population.
>>
>> I tried closing and reopening the DB connection, and the same thing
>> happened.
>>
>> So it seems like a bug in the ODocument() constructor?
>>
>>
>>
>>  --
>
> ---
> 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