Announcement Announcement Module
Collapse
No announcement yet.
From JPA to NOSQL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • From JPA to NOSQL

    Hello,
    I am trying to add a NOSQL data into my JPA-based application, following this tutorial.
    The entity I want to add, was befored modeled without NOSQL in this way:

    Triple.java

    Code:
    @Entity
        @IdClass(ConceptPk.class)
        @Table(name = "triple")
        public class TripleDBModel {
        	protected List<Annotation> annotations;
        	public Concept conceptUriSubject;
        	public Concept conceptUriObject;
        	public Concept conceptUriPredicate;
    
        	@ManyToMany(
        	        cascade={CascadeType.ALL },	
        	        fetch=FetchType.LAZY
        	)	
            @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;
        	}
    ConceptPk.java

    Code:
     @Embeddable
        public class ConceptPk implements java.io.Serializable {
        
        	private static final long serialVersionUID = 1L;
        	public Concept conceptUriSubject;
        	public Concept conceptUriObject;
        	public Concept conceptUriPredicate;
        
        	@Id 
        	@ManyToOne(cascade=CascadeType.MERGE)
        	@JoinColumn(name="uri_concept_subject")
        	public Concept getConceptUriSubject() {
        		return conceptUriSubject;
        	}
        	public void setConceptUriSubject(Concept conceptUriSubject) {
        		this.conceptUriSubject = conceptUriSubject;
        	}
    I am omiting repetitions, but the 3 `Concept`s are part of the primary key, of the @Id.
    Adapting this entity to NOSQL:

    Code:
    @Entity
        @IdClass(ConceptPk.class)
        @Table(name = "triple")
        @NodeEntity(partial = true)
        public class TripleDBModel {
        //Fields referring other entities shouldn't be initialized
        	protected List<Annotation> annotations;
        	//public Concept conceptUriSubject;
        	//public Concept conceptUriObject;
        	//public Concept conceptUriPredicate;
        
        	
        	@RelatedTo(type = "conceptUriSubject", elementClass = Concept.class)
            Set<Concept> conceptUriSubject;
    Now the question, which actually are two questions:

    A) `@RelatedTo(type = "conceptUriSubject", elementClass = Concept.class)` gives me error on Eclipse, and advises me to add a cast, but this doesn't solve the error. I don't know if I must an annotation or any other additional thing to `Class.java`

    B) As I have specified, the primery key is composed by 3 concepts, and `ConceptPK.java` is required. JPA modelling is ok, but I don't know how to do the same in NOSQL
Working...
X