本文整理了Java中org.neo4j.graphdb.Node.setProperty()
方法的一些代码示例,展示了Node.setProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.setProperty()
方法的具体详情如下:
包路径:org.neo4j.graphdb.Node
类名称:Node
方法名:setProperty
暂无
代码示例来源:origin: neo4j/neo4j
private void createNonUniqueNodes()
{
try ( Transaction tx = db.beginTx() )
{
Node originNode = db.createNode( LABEL );
originNode.setProperty( KEY, point1 );
Node centerNode = db.createNode( LABEL );
centerNode.setProperty( KEY, point1 );
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testNodeWithDoubleProperty()
{
final double doubleValue = 123456.123456;
final String expected = "123456.123456";
gdb.createNode().setProperty( "double", doubleValue );
assertEquals( "create (_0 {`double`:" + expected + "})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testPointTypeWithTwoOtherProperties()
{
Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 );
String key = "location";
node1.setProperty( "prop1", 1 );
node1.setProperty( "prop2", 2 );
node1.setProperty( key, point );
newTransaction();
Object property = node1.getProperty( key );
assertEquals( point, property );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void lookupWithoutTransaction()
{
// when
Node node;
try ( Transaction tx = db.beginTx() )
{
(node = db.createNode( label( "Node" ) )).setProperty( "prop", store );
tx.success();
}
// then
try ( Transaction tx = db.beginTx() )
{
assertEquals( 1, count( db.findNodes( label( "Node" ), "prop", lookup ) ) );
tx.success();
}
deleteNode( node );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void largeTx()
{
Node node = getGraphDb().createNode();
node.setProperty( "anchor", "hi" );
for ( int i = 0; i < 255; i++ )
{
node.setProperty( "foo", 1 );
node.removeProperty( "foo" );
}
commit();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void txMustFailIfExceedingIndexKeySizeLimit()
{
createIndex();
// Write
try ( Transaction tx = db.beginTx() )
{
String propValue = getString( keySizeLimit + 1 );
db.createNode( LABEL_ONE ).setProperty( propKey, propValue );
tx.success();
}
catch ( IllegalArgumentException e )
{
assertThat( e.getMessage(),
Matchers.containsString( "Property value size is too large for index. Please see index documentation for limitations." ) );
}
}
代码示例来源:origin: neo4j/neo4j
private void setProperty( Node node, String key, Object value )
{
try ( Transaction tx = db.beginTx() )
{
node.setProperty( key, value );
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
void setProperty( String nodeName, String propertyName, Object propertyValue )
{
Node i = this.getNode( nodeName );
GraphDatabaseService db = i.getGraphDatabase();
try ( Transaction tx = db.beginTx() )
{
i.setProperty( propertyName, propertyValue );
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
private void createAliens()
{
try ( Transaction tx = db.beginTx() )
{
for ( int i = 0; i < 32; i++ )
{
Node alien = db.createNode( ALIEN );
alien.setProperty( SPECIMEN, i / 2 );
}
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testNodeWithProperties()
{
gdb.createNode().setProperty( "name", "Andres" );
assertEquals( "create (_0 {`name`:\"Andres\"})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testPointTypeWithOneOtherProperty()
{
Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 );
String key = "location";
node1.setProperty( "prop1", 1 );
node1.setProperty( key, point );
newTransaction();
Object property = node1.getProperty( key );
assertEquals( point, property );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void lookupWithoutTransactionWithCacheEviction()
{
// when
Node node;
try ( Transaction tx = db.beginTx() )
{
(node = db.createNode( label( "Node" ) )).setProperty( "prop", store );
tx.success();
}
// then
try ( Transaction tx = db.beginTx() )
{
assertEquals( 1, count( db.findNodes( label( "Node" ), "prop", lookup ) ) );
tx.success();
}
deleteNode( node );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void addAndRemovePropertiesWithinOneTransaction()
{
Node node = getGraphDb().createNode();
node.setProperty( "name", "oscar" );
node.setProperty( "favourite_numbers", new Long[] { 1L, 2L, 3L } );
node.setProperty( "favourite_colors", new String[] { "blue", "red" } );
node.removeProperty( "favourite_colors" );
newTransaction();
assertNotNull( node.getProperty( "favourite_numbers", null ) );
}
代码示例来源:origin: neo4j/neo4j
@Test( timeout = 30_000 )
public void terminateExpiredTransaction() throws Exception
{
try ( Transaction transaction = database.beginTx() )
{
database.createNode();
transaction.success();
}
expectedException.expectMessage( "The transaction has been terminated." );
try ( Transaction transaction = database.beginTx() )
{
Node nodeById = database.getNodeById( NODE_ID );
nodeById.setProperty( "a", "b" );
executor.submit( startAnotherTransaction() ).get();
}
}
代码示例来源:origin: neo4j/neo4j
void setNodeProp( long nodeId, String propertyKey, String value )
{
try ( Transaction tx = db.beginTx() )
{
Node node = db.getNodeById( nodeId );
node.setProperty( propertyKey, value );
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
private static void createNode( GraphDatabaseService database, String propertyName, Label testLabel )
{
try ( Transaction transaction = database.beginTx() )
{
Node node = database.createNode( testLabel );
node.setProperty( propertyName, "value" );
transaction.success();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testNodeWithFloatProperty()
{
final float floatValue = 10.1f;
final String expected = "10.100000";
gdb.createNode().setProperty( "float", floatValue );
assertEquals( "create (_0 {`float`:" + expected + "})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testPointType()
{
Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 );
String key = "location";
node1.setProperty( key, point );
newTransaction();
Object property = node1.getProperty( key );
assertEquals( point, property );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testNodeAddPropertyWithNullKey()
{
Node node1 = getGraphDb().createNode();
try
{
node1.setProperty( null, "bar" );
fail( "Null key should result in exception." );
}
catch ( IllegalArgumentException ignored )
{
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void testPropertyStoreReferencesOnWrite() throws Throwable
{
// Given
GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
// and Given the cache contains a LazyProperty
long nId = ensurePropertyIsCachedLazyProperty( db, "some" );
// When
restartNeoDataSource( db );
// Then it should still be possible to manipulate properties on this node
try ( Transaction tx = db.beginTx() )
{
db.getNodeById( nId ).setProperty( "some", new long[]{-1, 2, 2, 3, 4, 5, 5} );
tx.success();
}
}
内容来源于网络,如有侵权,请联系作者删除!