Help with sleep exception

I have this POJO mapped to my MySQL database:

@Entity @Table(name = "participantespresentes", catalog = "tagit") public class Participantespresentes implements java.io.Serializable { private ParticipantespresentesId id; private Evento evento; private Usuario usuario; private boolean status; public Participantespresentes() { } public Participantespresentes(ParticipantespresentesId id, Evento evento, Usuario usuario, boolean status) { this.id = id; this.evento = evento; this.usuario = usuario; this.status = status; } @EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "idUsuario", column = @Column(name = "idUsuario", nullable = false)), @AttributeOverride(name = "idEvento", column = @Column(name = "idEvento", nullable = false))}) public ParticipantespresentesId getId() { return this.id; } public void setId(ParticipantespresentesId id) { this.id = id; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "idEvento", nullable = false, insertable = false, updatable = false) public Evento getEvento() { return this.evento; } public void setEvento(Evento evento) { this.evento = evento; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "idUsuario", nullable = false, insertable = false, updatable = false) public Usuario getUsuario() { return this.usuario; } public void setUsuario(Usuario usuario) { this.usuario = usuario; } @Column(name = "status", nullable = false) public boolean isStatus() { return this.status; } public void setStatus(boolean status) { this.status = status; } } 

And every time I try to perform any operation using hibernate, throw this exception:

 Initial SessionFactory creation failed.org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined: com.bytecode.entities.Evento.participantespresentes 

Any help?

Regards, Walter Enrique.

+4
source share
2 answers

The exception message is pretty clear - Hibernate cannot determine the type of the item in the Evento.participantespresentes collection. You must declare it as generic (i.e., as List<Participantespresentes> ).

+5
source

The problem is not in Entantespresentes, but in the Evento class. You have an attribute called members, but it is not displayed correctly. If you did not find a problem, send Evento code.

0
source

Source: https://habr.com/ru/post/1344931/


All Articles