Boa noite,
Estou tentando criar as tabelas no banco de dados, utilizando os conhecimentos adquiridos até o momento no curso de Hibernate, porem tenho recebido a seguinte mensagem de erro:
mar 08, 2016 9:38:29 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
mar 08, 2016 9:38:29 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.8.Final}
mar 08, 2016 9:38:29 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
mar 08, 2016 9:38:29 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: Associacao] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at bd.systems.associacao.jpa.TesteJPA.main(TesteJPA.java:19)
Caused by: org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: bd.systems.associacao.model.Colaborador.evento
at org.hibernate.cfg.annotations.CollectionBinder.getCollectionBinder(CollectionBinder.java:327)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1719)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:766)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:685)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3443)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3397)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1341)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
... 5 more
Segue o código da minha Entity "Colaborador", a qual tem sido frisada no erro do Hibernate.
@ManagedBean
@SessionScoped
@Entity
@Table (name="Colaborador")
public class Colaborador implements java.io.Serializable {
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
private String nome;
private String endereco;
private String bairro;
private String cidade;
private String estado;
private String telRes;
private String telCel;
@ManyToMany
@JoinColumn(name = "funcaoId")
private Funcao funcao;
@ManyToMany
@JoinColumn(name = "eventoId")
private Evento evento;
private boolean ativo;
//Getters and setters
E a Entity "Evento".
@ManagedBean
@SessionScoped
@Entity
@Table (name="Evento")
public class Evento implements java.io.Serializable {
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
private String descricao;
private int diasProgramacao;
@Temporal(TemporalType.DATE)
private LocalDate dataInicioEvento;
@Temporal(TemporalType.DATE)
private LocalDate dataFinalEvento;
private int horario;
private int duracaoEvento;
private int qtdeMaximaParticipantes;
private boolean ativo;
//Getters and setters
Não consegui compreender sobre o que está ocorrendo para ocasionar nesse problema. Desde já agradeço por qualquer ajuda dos colegas.