Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityManagerImpl.find doesn't generally work with NamedGraph annotated classes #120

Open
delocalizer opened this issue Oct 12, 2016 · 2 comments

Comments

@delocalizer
Copy link
Contributor

If MyClass is annotated with @NamedGraph (Static or Instance type doesn't matter) and an instance of the class lives in the database, EntityManagerImpl.find(MyClass, itsKey) won't find it.

See https://groups.google.com/forum/#!topic/empire-rdf/BKu0f5uItec

Unfortunately the fix is not as simple as calling
DataSourceUtil.exists(getDataSource(), theObj)

in EntityManagerImpl.find because theObj passed into find and thence to DataSourceUtil.exists is often (as in this case) just an RdfKey or similar key-like identifier with no annotations.

The problem is that EntityManager.find does (and should) accept a broad range of types as "theObj", where for instances of naked key types the additional NamedGraph information on where to find them lives only in separately-supplied "theClass" parameter, while the code that actually does the finding — DataSourceUtil.exists(DataSource theDataSource, Object theObj) — expects all the info to be available in theObj instance.

More broadly EmpireUtil.hasNamedGraphSpecified(Object theObj) and EmpireUtil.getNamedGraph(Object theObj) expect that information on the instance too.

@mhgrove
Copy link
Owner

mhgrove commented Oct 12, 2016

I had originally thought that maybe RdfKey would be a pair of the key value and the iri of the named graph. I wanted to avoid coupling those together, but, that might be a nice simplification that would resolve this issue.

Having urn:foo be a different entity when it's in named graph urn:g vs when it's in urn:g1 seems like it's probably what users would expect

@delocalizer
Copy link
Contributor Author

Yeah, having the graph be part of the key seems nice from a practical pov. I think it's also kosher from a RDF theory pov, not that I am an expert. My understanding that the intended usefulness of named graphs is for store-based operations, and RdfKey is the key to find the entity in the store.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants