Skip to content

Commit

Permalink
Use Kernel API to create nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusmelke committed Mar 14, 2018
1 parent 511da14 commit ac1e589
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -541,11 +541,13 @@ public Relationship createRelationshipTo( Node otherNode, RelationshipType type
//{
// throw new IllegalArgumentException( "Nodes do not belong to same graph database." );
//}
try ( Statement statement = spi.statement() )

KernelTransaction transaction = safeAcquireTransaction();
try ( Statement ignore = transaction.acquireStatement() )
{
int relationshipTypeId = statement.tokenWriteOperations().relationshipTypeGetOrCreateForName( type.name() );
long relationshipId = statement.dataWriteOperations()
.relationshipCreate( relationshipTypeId, nodeId, otherNode.getId() );
int relationshipTypeId = transaction.tokenWrite().relationshipTypeGetOrCreateForName( type.name() );
long relationshipId = transaction.dataWrite()
.relationshipCreate( nodeId, relationshipTypeId, otherNode.getId() );
return spi.newRelationshipProxy( relationshipId, nodeId, relationshipTypeId, otherNode.getId() );
}
catch ( IllegalTokenNameException e )
Expand Down

0 comments on commit ac1e589

Please sign in to comment.