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
ConceptPk.javaCode:@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; }
I am omiting repetitions, but the 3 `Concept`s are part of the primary key, of the @Id.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; }
Adapting this entity to NOSQL:
Now the question, which actually are two questions: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;
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


Reply With Quote
