ho una superclasse Questions
e la sua sottoclasse MultipleChoiceQuestions
uno a molti mappatura a una proprietà di superclasse
superclasse ha un campo activity
voglio creare un Set<MultipleChoiceQuestions>
e utilizzare OneToMany
annotazioni utilizzando mappedBy = "activity"
per esempio
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "activity")
private Set<NQIMultipleChoiceQuestions> mcqQuestions = new HashSet<NQIMultipleChoiceQuestions>();
sto ottenendo questo errore:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property
Tuttavia, funziona bene se creo un insieme di entità superclasse,
esempio
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "activity")
private Set<NQIQuestions> questions = new HashSet<NQIQuestions>();
C'è un modo per mappare alla proprietà della superclasse?
@sahil, le due linee che hanno mostrato - in cui si sosteneva che il primo non ha funzionato, ma il secondo ha fatto - si differenziano solo per il nome della variabile del 'set'. –
@binil: ya .. in realtà nel secondo caso, le domande è la classe base, mentre mcqQuestion è sottoclasse. – shailesh
@OneToMany (fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "activity") \t private Set questions = new HashSet (); –
shailesh