Reputation: 115
I have a problem, when I run hibernate it shows me the error of "Caused by: org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: com.trein.Moneda.documento"
, and the truth is I do not know why it is throwing this error.
It seems like its failing in Moneda.java
class
Documento.java
@ManyToOne
@JoinColumn(name = "pais_id", nullable = false)
private Pais pais;
@ManyToOne
@JoinColumn(name = "moneda_id", nullable = false)
private Moneda moneda;
@ManyToOne
@JoinColumn(name = "remesa_id", nullable = false)
private Remesa remesa_doc;
Moneda.java
@OneToMany(mappedBy = "moneda")
private Documento documento;
Upvotes: 0
Views: 2004
Reputation: 846
if you are expecting that Moneda
object has many Documento
object then you should make it List<Documento>
because @OneToMany
annotation expects the property to be a collection
of some objects.
Upvotes: 3