neo4j on .net 3.5

June 3rd, 2010 § 1

I recently ran across a project called ja.net that provides support for compilation of Java to .Net.  Since neo4j has such a dependency clean kernel, I decided to try ja.net as a way of making neo4j usefull under .Net. (no slight against the RESTful interfaces, but perhaps you’d like to run neo4j on .net as an embedded graph DB under .Net). Here’s my VS2010 with the neo4j.dll referenced, and the object browser showing the EmbeddedGraphDB class as a first class .Net object:

Step #1 Download stuff

Download the neo4j kernel source and expand into a working directory. http://neo4j.org/download

Download the geronimo JTA spec src jar and expand under neo4j’s src/main/java directory. 

Install Ja.net from http://www.janetdev.org/

Step #2 Compile neo4j kernel using Ja.Net

C:\neo4j-kernel-1.0\src>c:\opt\java\Ja.NET\bin\javac -bam:neo4j.dll main

You can compile first then using the “bam” command to create the dll, or do it in one pass as I’ve done here.  You’ll see warnings, most look like compiler warnings, one may be of concern.  For now let’s just experiment.  No garauntees, promises, etc. 

Step #3 Create a C# console app, reference your newly created .dll, and give neo4j on .net a run.  Here’s my sample code:

class Program
{
static void Main(string[] args)
{
var graphDb = new EmbeddedGraphDatabase("graphdb");
var tx = graphDb.beginTx();
try
{
var firstNode = graphDb.createNode();
var secondNode = graphDb.createNode();
var relationship = firstNode.createRelationshipTo(
secondNode, DynamicRelationshipType.withName("KNOWS"));
firstNode.setProperty("message", "Hello, ");
secondNode.setProperty("message", "world!");
relationship.setProperty("message", "brave Neo4j ");
var i = graphDb.getAllNodes().iterator();
while (i.hasNext()) {
    var n = ((Node)i.next());
    if (n.hasProperty("message"))
    Console.WriteLine(n.getProperty("message"));
}
Console.WriteLine("bye");
tx.success();
}
finally
{
   tx.finish();
   graphDb.shutdown();
}
Console.ReadLine();
}

Jo4neo’s “get most recent” feature

January 10th, 2010 § 2

“show the latest ….” is a common prefix to user stories these days.  Others have noted the same and given this symptom a moniker; ”The real time web“.  Typically we just throw things into a table with an indexed timestamp column and query accordingly.

In jo4neo, finding the most recent additions requires two simple steps:

  1. annotation your type with @neo(recency=true)
  2. use the ObjectGraph.getMostRecent() method to retrieve the latest inserts.

In this small example, we’re indicating to jo4neo that we’d like it to remember our “Post” inserts in most recent order. » Read the rest of this entry «

Indexing time and URI’s in jo4neo

January 6th, 2010 § 0

Graphs in and of themselves are not self indexing like relational databases, however, you can construct indexes via strong relationships between the nodes of interest.  The pattern I’ll be discussing in this post maps time (year, month, day, hour) into a graph format as nodes and edges.  Once time, or some subset, is represented as a graph we can then associate events or moment intervals as nodes related to a particular hour of a particular day, month and year.  ( This post is based on a full example here.) » Read the rest of this entry «

Regarding the Web-Oriented Architecture Un-Manifesto

January 4th, 2010 § 0

Dion Hinchcliffe details 17 principles in his recent blog post entitled “A Web-Oriented Architecture (WOA) Un-Manifesto“.  It’s nice to see somebody attempt to steer (if ever so slightly) away from the “manifesto” cliché… » Read the rest of this entry «

Simple Blog Using jo4neo and Stripes

January 3rd, 2010 § 0

neoblog is a simple application I built to test drive jo4neo.  You are welcome to browse the code here for details not covered in this post. It demonstrates the feasibility of utilizing view tier objects to persist graph relationships.

neoblog with 3 posts

neoblog with 3 posts

» Read the rest of this entry «

User/Roles Pattern in jo4neo

December 18th, 2009 § 0

Roles and Users is a classic domain model well suited to representation as a directed graph. The neo4j team has provided us with a good summary of how to implement this pattern using neo4j here . Utilizing jo4neo we can also solve this problem via a combination of the neo graph database and simple java objects.  The code and maven build for this example are posted here.  I encourage you to run the example and browse the code.  We’ll need two domain classes, » Read the rest of this entry «

User/Roles Pattern in OWL

December 10th, 2009 § 0

The standard User-Role or User-Group pattern is typically implemented as three tables; User, Group, and an associative table User_Group. OWL (Ontology Web Language) is particularly suited to modeling this pattern, and, with a little help from an inferencing engine, can make some obvious yet valuable inferences for us.  In many organizations it’s easier to model roles as a set of interrelated nodes such that membership in one conveys membership in a broader group.  In this diagram Mark  is declared as having a “marketing” role, however, he’s also an employee, and the graph makes that clear.  If we were using the standard RDBMS approach mentioned above we’d have to enumerate each group and assert his membership to each one in the associative table.

users and roles

users and roles


» Read the rest of this entry «

jo4neo: POJO object binding 4 neo4j 4 you!

December 9th, 2009 § 1

I have applied some of what I learned while writing jenabean towards a graph database called neo4j. It is strictly a simple tool for persisting java objects to a graph, and retrieving them back. I was able to get in a few features like auto-indexing. This is version 0.1…a very early release.

http://code.google.com/p/jo4neo/

Rocket

November 24th, 2009 Comments Off

Try and find the disco ball.
rocket

3 Software Architecture Trends for 2010

November 16th, 2009 § 3

I’ve recently returned from the Øredev developer’s conference in Malmo, Sweden where I had the privilege of  sharing knowledge with a very eclectic group of technologists . In addition to existing trends such as language agnosticism on the JVM, Agile, and mobile proliferation I noticed 3 emerging trends that stood out. Some of the concepts will be familiar to you and while they are not drastic departures from the past, they are significant and becoming more prominent and recognizable as we near the end of 2009.

» Read the rest of this entry «