4

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 everytime that i try to execute any operation with hibernate, launch 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 ?

Best regards, Valter Henrique.

2
  • It seems to be a problem with the participatespresentes the Evento class. Can you show us the Evento class? Commented Mar 23, 2011 at 14:33
  • 1
    Btw, it's good practice to keep the code (class name, method name, variable name, etc.) in English. Commented Mar 23, 2011 at 14:34

2 Answers 2

5

Exception message is pretty clear - Hibernate cannot determine element type of collection Evento.participantespresentes. You need to declare it as generic (i.e. as List<Participantespresentes>).

Sign up to request clarification or add additional context in comments.

1 Comment

a good explanation for it is also found here mkyong.com/hibernate/…
0

The problem is not in Participantespresentes, but in the class Evento. You have there an attribute called participantespresentes, but it's not mapped properly. If don't find the problem, please post the code of Evento.

1 Comment

i follow the recommendation below @Augusto, thanks by your help, it give me a lead. Cheers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.