Announcement Announcement Module
No announcement yet.
@RelatedTo(elementClass = Concept.class) RelatedTo.elementClass must be a class liter Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @RelatedTo(elementClass = Concept.class) RelatedTo.elementClass must be a class liter

    Reading this documentation, I tryed to apply to my code in this way:


    @Table(name = "triple")
    public class TripleDBMoldelNeoImpl implements TripleDBModel{
    	protected List<Annotation> annotations;
    	@RelatedTo(type = "subject", elementClass = (Class<? extends NodeBacked>) Concept.class) //This is the suggestion Eclipse gives me
    	public Concept subject;
    	@RelatedTo(type = "object", elementClass = Concept.class)
    	public Concept object;
    	@RelatedTo(type = "predicate", elementClass = Concept.class)
    	public Concept predicate;
    	        cascade={CascadeType.ALL },	
        @JoinTable(name = "triple_has_annotation", 
        		joinColumns={@JoinColumn(name="uri_concept_subject"), @JoinColumn(name="uri_concept_object"), @JoinColumn(name="uri_concept_predicate") },  		
        		inverseJoinColumns=@JoinColumn(name="annotation_id") )
        public List<Annotation> getAnnotations() {
    		return annotations;
    	public void setAnnotations(List<Annotation> annotations) {
    		this.annotations = annotations;
    	@Column(name = "subject", length = 100)
    	public Concept getSubject() {
    		return subject;
    	public void setSubject(Concept subject) {
    		this.subject = subject;
    	@Column(name = "object", length = 100)
    	public Concept getObject() {
    		return object;
    	public void setObject(Concept object) {
    		this.object = object;
    	@Column(name = "predicate", length = 100)
    	public Concept getPredicate() {
    		return predicate;
    	public void setPredicate(Concept predicate) {
    		this.predicate = predicate;
    @NodeEntity(partial = true)
    public class ConceptNeoImpl implements, Concept {
    	private static final long serialVersionUID = 1L;
    	private String uri;
    	private String label;
    	private String ontologyElement;
    	private List<Annotation> annotations;
    	@RelatedTo(type = "conceptSub", elementClass = TripleDBModel.class)
    	private TripleDBModel triple;
    	public TripleDBModel getTriple() {
    		return triple;
    	public void setTriple(TripleDBModel triple) {
    		this.triple = triple;

    The use I want to is explained on the image below


    Then, the table triple will be using neo4j and concept will be using jpa and neo4j. I am programming using Eclipse IDE and it gives me suggestions to correct the errors. The first one is:
    @RelatedTo(type = "conceptUriSubject", elementClass = Concept.class)
    correct to
    @RelatedTo(type = "conceptUriSubject", elementClass = (Class<? extends NodeBacked>) Concept.class)
    And then, the problem is not solved, and gives me the nex message

    Multiple markers at this line
    - The value for annotation attribute RelatedTo.elementClass must be a class literal
    - Type safety: Unchecked cast from Class<Concept> to Class<? extends
    - The value for annotation attribute RelatedTo.elementClass must be a class literal
    - Type safety: Unchecked cast from Class<Concept> to Class<? extends
    Any ideas¿¿ I am new on this, so I am quite lost. Thanks in advance

    The image attached is not clear. I try to explain with words:
    TRIPLE -> the id is composed by 3
    CONCEPT -> is related to TRIPLE by a triple relation. 3 concepts will be related with one TRIPLE

    Even checking more exaplnes I found in Internet, I can't see the different between them and my example. Any help please??
    Attached Files
    Last edited by mujer_esponja; May 16th, 2011, 08:53 AM. Reason: Image attached is not clear

  • #2

    I already tried to answer it in the mailing list, will copy that answer here so that other people can find it too.

    Your Concept is an interface and does not extend NodeBacked right now.

    In general: the NodeBacked interface is added to classes that have the @NodeEntity annotation.

    Then you might try the same solution.

    * either annotate Concept with @NodeEntity too.
    * or have Concept extend NodeBacked on itself

    * elementClass should rather refer to the concrete implementation (this might work with the interface though as it is just used to check for compatibility with the target).

    And please report back on the success of this.




    • #3
      Yes Michael, thank you again.
      I had some other mistakes related to my structure, but this is the solution for this problem.