Recent Posts
None | 5 sec ago
Lua | 13 sec ago
None | 18 sec ago
None | 18 sec ago
None | 39 sec ago
None | 41 sec ago
None | 50 sec ago
PHP | 1 min ago
None | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Stefan on the 9th of Feb 2010 08:20:55 PM Download | Raw | Embed | Report
  1. import org.neo4j.kernel.EmbeddedGraphDatabase;
  2. import org.neo4j.graphdb.GraphDatabaseService;
  3. import org.neo4j.graphdb.Transaction;
  4. import org.neo4j.graphdb.DynamicRelationshipType;
  5. import org.neo4j.graphdb.Node;
  6. import org.neo4j.graphdb.Relationship;
  7.  
  8. class neo {
  9.  
  10.         public static void main(String[] args) {
  11.  
  12.                 GraphDatabaseService graphDatabaseService = new EmbeddedGraphDatabase("/tmp/neo4jdb");
  13.                 Transaction tx = graphDatabaseService.beginTx();
  14.                 try {
  15.                         Node root = graphDatabaseService.getReferenceNode();
  16.                         Node node = graphDatabaseService.createNode();
  17.                         long id = node.getId();
  18.    
  19.                         node.createRelationshipTo(root, DynamicRelationshipType.withName("dummy"));
  20.    
  21.                         for (Relationship rel : root.getRelationships()) {
  22.                                 System.out.format("rel %s: %s -> %s %s\n", rel, rel.getStartNode(), rel.getEndNode(), rel.getType().name());
  23.                         }
  24.  
  25.                         node.delete(); // this should throw a RuntimeException                 
  26.  
  27.                         node = graphDatabaseService.getNodeById(id);
  28.                         System.out.format("node is still there %s\n", node);
  29.  
  30.                         tx.failure();
  31.                         System.out.println("no exception occured");
  32.                 } catch (Throwable e) {
  33.                         e.printStackTrace();
  34.                 } finally {
  35.                         tx.finish();
  36.                         graphDatabaseService.shutdown();
  37.                 }
  38.         }
  39. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: