You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Claude Warren <cl...@xenei.com> on 2012/06/29 18:32:48 UTC
JPA like annotations for Jena
Greetings,
I have a package that implements JPA like annotations for Jena. However,
it takes a twist on JPA by assuming that the data are in models not in a
database and so there are some interesting differences like the ability to
remove one object from a set of objects that match <subject, predicate, ?o>.
The net result is a set of 3 annotations (Subject, Predicate and URI) that
can be applied to an interface and an EntityManager that converts Resource
objects into the interface implementation using dynamic proxies.
for example:
@Subject( namespace="http://example.org/book/")
interface Book {
@Predicate( namespace="http://purl.org/dc/elements/1.1/" )
void setTitle(String newTitle);
String getTitle();
Boolean hasTitle()
@Predicate( namespace="http://purl.org/dc/elements/1.1/" )
void setTitle(String newTitle);
String getTitle();
Boolean hasTitle()
}
Would allow you to call
Resource r = .... // read resource from book example model
Book book= EntityManager.read( r, Book.class )
book.setTitle( "My Fair Lady" );
I have a set of 88 test cases that validate the parsing of the Subject
annotated classes and the implementation of the dynamic proxies.
The implementation covers all basic java types (including primitives) and
the ability to retrieve other annotated Classes.
For example
@Subject( namespace="http://example.org/library/ <http://example.org/book/>
")
interface Library {
@Predicate
void addHolding(Book book);
void removeHolding( Book book );
ExtendedIterator<Book> getHolding();
Boolean hasHolding(Book book );
}
Would create a Library class that has multiple Books listed in its holding.
I am going to release this as open source in the near future and am
wondering if anyone has any interest in using this.
Claude
--
I like: Like Like - The likeliest place on the web<http://like-like.xenei.com>
Identity: https://www.identify.nu/user.php?claude@xenei.com
LinkedIn: http://www.linkedin.com/in/claudewarren