I have two entities being stored in Stardog and managed by Empire, they are Cat and Dog.
I have a webservice that updates the name of a Dog, if this webservice is given the Id of a Cat Empire returns a Dog object and I end up with an object that is both a Cat and a Dog.
For example:
My triple store has the following
Subject Predicate Object
http://www.domain.com/pets#1 rdf:type http://www.domain.com/pets#Cat
http://www.domain.com/pets#1 http://www.domain.com/pets#hasName Frank
I call the webservice to update a Dog with id "http://www.domain.com/pets#1" and a new name "Mark"
Empire returns a Dog even though the datastore says its type is Cat. The returned Dog object will have a name populated because Empire will map any properties that are on Dog (both my Dog and Cat class have a "name" property).
Dog dog = entityManager.find(Dog.class, entityUri);
Then the service updates the name and persist it.
dog.setName(updatedName);
entityManager.merge(dog);
The datastore now has two types for this entity Cat and Dog.
Subject Predicate Object
http://www.domain.com/pets#1 rdf:type http://www.domain.com/pets#Cat
http://www.domain.com/pets#1 rdf:type http://www.domain.com/pets#Dog
http://www.domain.com/pets#1 http://www.domain.com/pets#hasName Mark
Is there a way for the EntityManager to return null or throw an exception if the id does not have the same type as what is passed in?
I could run a sparql query first to check that the id is of the type I’m trying to get back but I feel like it’s something the EntityManager should take care of.
I could run a sparql query first to check that the id is of the type I’m trying to get back but I feel like it’s something the EntityManager should take care of.
--
You received this message because you are subscribed to the Google Groups "Empire" group.
To unsubscribe from this group and stop receiving emails from it, send an email to empire-rdf+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.