I'm a Java developer just getting started with linked data/RDF. I can create triples, put them in a triple store, query them, etc, but it's very awkward. Most of my code is focused on the mechanics of RDF and I'd really like to work with this data in a way that's more idiomatic Java.
How can I convert a POJO to/from RDF triples with Jena without hand-coding everything?
I'd like something that can convert a pile of triples with a defined structure back and forth between a Java POJO and RDF. Like JAXB or and ORM does for XML and a relational database, respectively.
Also, I can't be locked in too closely a particular triple store. I'd really like something that works with the Apache Jena API, since that seems to be the closest to an "industry standard." Also the project architect told me to use that, since the triple stores they're investigating all support it.
Stuff I've looked at:
I try out one library that sort of does what I want, but it made some weird choices and I don't really think it will work for me.
Elmo/Alibaba also sounds promising, but it looks like it only works with the Sesame triple store and it also sounds like it may carry a big giant framework and/or server along with it. Has anyone had any success using it with Jena? I haven't actually tried it out.
There's Empire which is a partial implementation of JPA 1.0 for Object-Triple mapping. It supports Jena, Sesame, and Stardog out of the box, and is pretty easy to add support for other databases.
There's also Pinto which is more akin to Jackson. It's more lightweight than Empire and just does round-tripping to/from RDF & Java beans. It will soon be the engine inside of Empire.
Disclaimer: I'm the author of both.
Another possible tool to look at is OLGA - an Ontology SDK. See https://ecostruxure.github.io/OLGA/ .
来源:https://stackoverflow.com/questions/34098348/how-can-i-easily-convert-rdf-triples-to-from-an-idiomatic-java-pojo-business-obj