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...
By Stefan on the 9th of Feb 2010 08:20:55 PM
Download |
Raw |
Embed |
Report
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
class neo {
public static void main
(String[] args
) {
GraphDatabaseService graphDatabaseService = new EmbeddedGraphDatabase("/tmp/neo4jdb");
Transaction tx = graphDatabaseService.beginTx();
try {
Node root = graphDatabaseService.getReferenceNode();
Node node = graphDatabaseService.createNode();
long id = node.getId();
node.createRelationshipTo(root, DynamicRelationshipType.withName("dummy"));
for (Relationship rel : root.getRelationships()) {
System.
out.
format("rel %s: %s -> %s %s\n", rel, rel.
getStartNode(), rel.
getEndNode(), rel.
getType().
name());
}
node.delete(); // this should throw a RuntimeException
node = graphDatabaseService.getNodeById(id);
System.
out.
format("node is still there %s\n", node
);
tx.failure();
System.
out.
println("no exception occured");
e.printStackTrace();
} finally {
tx.finish();
graphDatabaseService.shutdown();
}
}
}
Submit a correction or amendment below.
Make A New Post