本文整理了Java中org.neo4j.internal.kernel.api.Write.relationshipRemoveProperty()
方法的一些代码示例,展示了Write.relationshipRemoveProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Write.relationshipRemoveProperty()
方法的具体详情如下:
包路径:org.neo4j.internal.kernel.api.Write
类名称:Write
方法名:relationshipRemoveProperty
[英]Remove a property from a relationship
[中]从关系中删除属性
代码示例来源:origin: neo4j/neo4j
@Override
public Object removeProperty( String key )
{
KernelTransaction transaction = spi.kernelTransaction();
try ( Statement ignore = transaction.acquireStatement() )
{
int propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
return transaction.dataWrite().relationshipRemoveProperty( id, propertyKeyId ).asObjectCopy();
}
catch ( EntityNotFoundException e )
{
throw new NotFoundException( e );
}
catch ( IllegalTokenNameException e )
{
throw new IllegalArgumentException( format( "Invalid property key '%s'.", key ), e );
}
catch ( InvalidTransactionTypeKernelException e )
{
throw new ConstraintViolationException( e.getMessage(), e );
}
catch ( AutoIndexingKernelException e )
{
throw new IllegalStateException( "Auto indexing encountered a failure while removing property: "
+ e.getMessage(), e );
}
}
代码示例来源:origin: neo4j/neo4j
assertThat( tx.dataWrite().relationshipRemoveProperty( relationshipId, token ),
equalTo( intValue( 42 ) ) );
assertThat( tx.dataWrite().relationshipRemoveProperty( relationshipId, token ),
equalTo( NO_VALUE ) );
tx.success();
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeAbleToRemoveResetAndTwiceRemovePropertyOnRelationship() throws Exception
{
// given
Transaction transaction = newTransaction( AnonymousContext.writeToken() );
int prop = transaction.tokenWrite().propertyKeyGetOrCreateForName( "foo" );
int type = transaction.tokenWrite().relationshipTypeGetOrCreateForName( "RELATED" );
long startNodeId = transaction.dataWrite().nodeCreate();
long endNodeId = transaction.dataWrite().nodeCreate();
long rel = transaction.dataWrite().relationshipCreate( startNodeId, type, endNodeId );
transaction.dataWrite().relationshipSetProperty( rel, prop, Values.of( "bar" ) );
commit();
// when
Write write = dataWriteInNewTransaction();
write.relationshipRemoveProperty( rel, prop );
write.relationshipSetProperty( rel, prop, Values.of( "bar" ) );
write.relationshipRemoveProperty( rel, prop );
write.relationshipRemoveProperty( rel, prop );
commit();
// then
transaction = newTransaction();
assertThat( relationshipGetProperty(transaction, rel, prop ), equalTo( Values.NO_VALUE ) );
commit();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldRemoveNonExistingPropertyFromRelationship() throws Exception
{
// Given
long relationshipId;
String propertyKey = "prop";
try ( org.neo4j.graphdb.Transaction tx = graphDb.beginTx() )
{
Node node1 = graphDb.createNode();
Node node2 = graphDb.createNode();
Relationship proxy = node1.createRelationshipTo( node2, RelationshipType.withName( "R" ) );
relationshipId = proxy.getId();
tx.success();
}
// When
try ( Transaction tx = beginTransaction() )
{
int token = tx.token().propertyKeyGetOrCreateForName( propertyKey );
assertThat( tx.dataWrite().relationshipRemoveProperty( relationshipId, token ),
equalTo( NO_VALUE ) );
tx.success();
}
// Then
try ( org.neo4j.graphdb.Transaction ignore = graphDb.beginTx() )
{
assertFalse( graphDb.getRelationshipById( relationshipId ).hasProperty( "prop" ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldRemovePropertyFromRelationship() throws Exception
{
// Given
long relationshipId;
String propertyKey = "prop";
try ( org.neo4j.graphdb.Transaction tx = graphDb.beginTx() )
{
Node node1 = graphDb.createNode();
Node node2 = graphDb.createNode();
Relationship proxy = node1.createRelationshipTo( node2, RelationshipType.withName( "R" ) );
relationshipId = proxy.getId();
proxy.setProperty( propertyKey, 42 );
tx.success();
}
// When
try ( Transaction tx = beginTransaction() )
{
int token = tx.token().propertyKeyGetOrCreateForName( propertyKey );
assertThat( tx.dataWrite().relationshipRemoveProperty( relationshipId, token ),
equalTo( intValue( 42 ) ) );
tx.success();
}
// Then
try ( org.neo4j.graphdb.Transaction ignore = graphDb.beginTx() )
{
assertFalse( graphDb.getRelationshipById( relationshipId ).hasProperty( "prop" ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldNotAllowModifyingPropertiesOnDeletedRelationship() throws Exception
{
// given
Transaction transaction = newTransaction( AnonymousContext.writeToken() );
int prop1 = transaction.tokenWrite().propertyKeyGetOrCreateForName( "prop1" );
int type = transaction.tokenWrite().relationshipTypeGetOrCreateForName( "RELATED" );
long startNodeId = transaction.dataWrite().nodeCreate();
long endNodeId = transaction.dataWrite().nodeCreate();
long rel = transaction.dataWrite().relationshipCreate( startNodeId, type, endNodeId );
transaction.dataWrite().relationshipSetProperty( rel, prop1, Values.stringValue( "As" ) );
transaction.dataWrite().relationshipDelete( rel );
// When
try
{
transaction.dataWrite().relationshipRemoveProperty( rel, prop1 );
fail( "Should have failed." );
}
catch ( EntityNotFoundException e )
{
assertThat( e.getMessage(), equalTo( "Unable to load RELATIONSHIP with id " + rel + "." ) );
}
commit();
}
代码示例来源:origin: neo4j/neo4j
tx.dataWrite().relationshipRemoveProperty( relationship, prop1 );
assertTrue( hasProperties( cursor, tx ) );
tx.dataWrite().relationshipRemoveProperty( relationship, prop2 );
assertTrue( hasProperties( cursor, tx ) );
tx.dataWrite().relationshipRemoveProperty( relationship, prop3 );
assertFalse( hasProperties( cursor, tx ) );
代码示例来源:origin: neo4j/neo4j
assertEquals( tx.dataWrite().relationshipRemoveProperty( relationshipId, propToken ),
stringValue( "hello" ) );
assertEquals( tx.dataWrite().relationshipSetProperty( relationshipId, propToken, stringValue( "world" ) ),
代码示例来源:origin: neo4j/neo4j
assertEquals( tx.dataWrite().relationshipRemoveProperty( relationshipId, propToken ),
stringValue( "hello" ) );
try ( RelationshipScanCursor relationship = tx.cursors().allocateRelationshipScanCursor();
代码示例来源:origin: org.neo4j/neo4j-kernel
@Override
public Object removeProperty( String key )
{
KernelTransaction transaction = spi.kernelTransaction();
try ( Statement ignore = transaction.acquireStatement() )
{
int propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
return transaction.dataWrite().relationshipRemoveProperty( id, propertyKeyId ).asObjectCopy();
}
catch ( EntityNotFoundException e )
{
throw new NotFoundException( e );
}
catch ( IllegalTokenNameException e )
{
throw new IllegalArgumentException( format( "Invalid property key '%s'.", key ), e );
}
catch ( InvalidTransactionTypeKernelException e )
{
throw new ConstraintViolationException( e.getMessage(), e );
}
catch ( AutoIndexingKernelException e )
{
throw new IllegalStateException( "Auto indexing encountered a failure while removing property: "
+ e.getMessage(), e );
}
}
内容来源于网络,如有侵权,请联系作者删除!