You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using RDFBeans (annotated interfaces) with success and would like to make use of anonymous/blank nodes now. I've followed every step from the documentation, but everytime I'm trying to assign an anonymous bean to another bean (calling setter of property) it throws an exception saying, that @RDFSubject annotation is missing. My code is:
KT aBean = this.manager.create(ID_UNKNOWN, beanType);
aBean.setId(null); //reset to make anonymous - id not set
bBean.setProp(aBean); //throws exception
I've tried a second way to solve my problem. This time I've explictely created an anonymous node and tried to create the bean afterwards:
Resource r = SimpleValueFactory.getInstance().createBNode();
Context ctx = this.manager.create(r, Context.class);
Unfortunately, this appraoch resulted in a different exception:
java.lang.ClassCastException: org.eclipse.rdf4j.model.impl.SimpleBNode cannot be cast to org.eclipse.rdf4j.model.IRI
As none of my solutions work I'm guessing that anonymous RDFBeans only work for classes and not for interfaces. Is that right? Or could someone tell me what I am doing wrong and point me into the correct direction?
Thanks in advance,
Thorben
The text was updated successfully, but these errors were encountered:
Yes, using RDFBean classes, it is possible to instantiate a bean without @RDFSubject value and assign it to properties of other beans. The anonymous bean will be represented as a BNode in the RDF model.
Instantiating a proxy object for a RDFBean interface requires an explicit resource identifier, so it doesn't work this way.
Perhaps, it makes sense to change the type of the create() argument from Resource to IRI, to make this explicit and avoid confusion.
Wouldn't it make sense to fix this "problem" instead of changing the method signature? If creating an anonymous bean from class already works it shouldn't be a big issue to make this working for interfaces as well: an anonymous RDFBean (mapped by class) should already be assigned a generated ID that could be assigend to a RDFBean (mapped by interface) as well. From my point of view this should already solve the problem, shouldn't it?
Hi all,
I'm using RDFBeans (annotated interfaces) with success and would like to make use of anonymous/blank nodes now. I've followed every step from the documentation, but everytime I'm trying to assign an anonymous bean to another bean (calling setter of property) it throws an exception saying, that @RDFSubject annotation is missing. My code is:
KT aBean = this.manager.create(ID_UNKNOWN, beanType);
aBean.setId(null); //reset to make anonymous - id not set
bBean.setProp(aBean); //throws exception
I've tried a second way to solve my problem. This time I've explictely created an anonymous node and tried to create the bean afterwards:
Resource r = SimpleValueFactory.getInstance().createBNode();
Context ctx = this.manager.create(r, Context.class);
Unfortunately, this appraoch resulted in a different exception:
java.lang.ClassCastException: org.eclipse.rdf4j.model.impl.SimpleBNode cannot be cast to org.eclipse.rdf4j.model.IRI
As none of my solutions work I'm guessing that anonymous RDFBeans only work for classes and not for interfaces. Is that right? Or could someone tell me what I am doing wrong and point me into the correct direction?
Thanks in advance,
Thorben
The text was updated successfully, but these errors were encountered: