W3C home > Mailing lists > Public > www-rdf-interest@w3.org > December 2004

Re: Object triple Mapping

From: Henry Story <henry.story@bblfish.net>
Date: Fri, 24 Dec 2004 21:12:31 +0100
Message-Id: <24512F02-55E8-11D9-BCBC-000A95D9FA7A@bblfish.net>
Cc: jena-dev@yahoogroups.com, www-rdf-interest@w3.org, bloged <users@bloged.dev.java.net>, kowari-general@lists.sourceforge.net
To: Max Voelkel <max@xam.de>

Thanks Max. rdfreactor [1] looks very much like what I had in mind.

To describe my (very initial thoughts) a little more I wrote the 
following on the Sesame web site [2]

The problem is essentially the same that JDO and hibernate are 
attempting to solve. But you are right: those tools attempt to work on 
persistence where the starting point is the java objects and classes. 
This is natural when working with Relational databases, as arguably the 
relational database are a level of abstraction lower than the OO code. 
In the case of RDF and OWL the database may have the upper hand. OWL is 
very close to a declarative form of OO programming, but allows multiple 
inheritance, and lots of other nice features. In my case, writing 
BlogEd, I did in fact start from an OWL ontology, then wrote some java 
classes that mapped the OWL classes. So for example I used the Atom 
Entry class which in OWL I defined as having the following relations

      author: which maps an entry to a Person
      id: which maps an entry to a uri (identifying the different 
versions of an entry)
      title: which maps an entry to a String
      content: which maps an entry to a Content object
      created: which maps an entry to a Date

in java this would of give a class such as

class Entry {
      Person author;
      Node id:
      String title;
      Content content;
      Date created;
      //setter and getter methods

Now if this Entry class is created directly from the OWL spec, this 
would be very nice. Perhaps others are in a situation where the inverse 
would be nice: the creation of an OWL ontology or mapping from some 
class specifications.

RDF does make a lot of things very easy though. Every RDF object is a 
URI. These play a role similar it seems to me to a java pointer, except 
that they can be universal. So we would like to ask the database 
questions such as "give me all the Entry objects", and have a 
java.util.List<Entry> returned. In the case of BlogEd, which uses the 
Sesame filesystem database, where the calls are cheap, and which does 
not need to make a lot of database queries, all the Entries in the list 
could be lazily evaluated: when one makes a call such as


the object would get the relevant string from the RDF Database, ie: the 
code could be implemented as

     public String getTitle() {
        if (title == null) {
            StatementIterator s =graph.getStatements(this.id, 
atom.title, null);
		   if (s != null)
              title = (String)s.next().getObject();
         return title;

Perhaps other applications would rather the database do the caching, 
and fill up the object during the initial factory construction call. In 
any case a lot of the code here is repetitive, and it seems easily 
automated. Perhaps this is the kind of job to do using aspects, perhaps 
dynamic proxies, perhaps using java 5 tags (which comes down to using 
aspects but in an easier to understand manner) as the next version of 
hibernate has chosen to do. The question should perhaps be: what 
remains to be hand coded? Probably the application specific data 
verification procedures.

Anyway it seems like there is space here for different solutions that 
help facilitate the mapping between java objects and an rdf database in 
the way hibernate helps between java objects and relational databases. 
I thought I had better check out first to see what is available before 
rolling my own. Perhaps rdfreactor is the tool I was looking for :-)


On 24 Dec 2004, at 14:08, Max Völkel wrote:
> Hi Henry,
> HS> Does anyone here have any thoughts on how best to achieve object
> HS> tripple mapping in rdf space? There are many tools to map POJO 
> (Plain
> HS> old Java Objects) to relational databases now: Hibernate [1], JDO 
> [2],
> HS> and others.
> I am not sure, whether this meets your requirements, but there is a
> project called RDFReactor [1] that takes an RDF Schema and generates 
> java
> interfaces from it. Then you can query and update an rdf model using
> bean-style java-methods. Not quite what you want, but somehow close, i
> guess. As i co-developped this project i would like to get your
> feedback.
> HS> It should be much easier to do this in RDF as the model is much
> HS> simpler, especially if one has an OWL ontology to work with.  
> Perhaps
> HS> the problem is fundamentally the same as with relational database. 
> But
> HS> perhaps triples open up new spaces that just were not clearly 
> available
> HS> with relational databases...
> What would be uses cases for java object persistence as rdf models? I
> never thought of that.
>  [1] http://rdfreactor.ontoware.org
>   Max
[2] I wish one could also e-mail that wiki!
Received on Friday, 24 December 2004 20:12:40 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:07:54 UTC