public void nodeWrapperSetUsage() { Node baseNode = graphDb.createNode(); Node itemNode1 = graphDb.createNode(); Node itemNode2 = graphDb.createNode(); Collection<MyDomainObject> items = new NodeWrapperRelationshipSet<MyDomainObject>( baseNode, ExampleTypes.MY_TYPE, MyDomainObject.class ); MyDomainObject item1 = new MyDomainObject( itemNode1 ); MyDomainObject item2 = new MyDomainObject( itemNode2 ); items.add( item1 ); items.add( item2 ); for ( MyDomainObject item : items ) { // Do something with the item } }
private void addNode( EmbeddedGraphDatabase graphDb ) { Node referenceNode = graphDb.getReferenceNode(); Node node = graphDb.createNode(); referenceNode.createRelationshipTo( node, MyRels.TEST ); } }
private Node addNode( EmbeddedGraphDatabase graphDb ) { Node referenceNode = graphDb.getReferenceNode(); Node node = graphDb.createNode(); node.setProperty( "theId", node.getId() ); referenceNode.createRelationshipTo( node, MyRels.TEST ); return node; } }
private Node addNode( EmbeddedGraphDatabase graphDb ) { Node referenceNode = graphDb.getReferenceNode(); Node node = graphDb.createNode(); node.setProperty( "theId", node.getId() ); referenceNode.createRelationshipTo( node, MyRels.TEST ); return node; } }
@Test public void handleArrayValues() { Node node = graphDb.createNode(); // START SNIPPET: handleArrayValues node.setProperty( "numbers", 5 ); List<Object> oneNumber = GraphDatabaseUtil.getPropertyValues( node, "numbers" ); // Will contain one item (5). node.setProperty( "numbers", new int[] { 5, 10, 15 } ); List<Object> numbers = GraphDatabaseUtil.getPropertyValues( node, "numbers" ); // Will contain three items (5, 10, 15). // There's also methods for adding/removing values to/from a property. GraphDatabaseUtil.removeValueFromArray( node, "numbers", 10 ); GraphDatabaseUtil.addValueToArray( node, "numbers", 20 ); List<Object> newNumbers = GraphDatabaseUtil.getPropertyValues( node, "numbers" ); // Will contain three items (5, 15, 20). // END SNIPPET: handleArrayValues }
try Node node1 = graphDb.createNode(); index.index( node1, "backup_test", "1" ); tx.success(); try Node node2 = graphDb.createNode(); index.index( node2, "backup_test", "2" ); tx.success();