Bom dia galera,
O mesmo projeto que eu utiliza anteriormente desktop está me apresentando alguns erros nos mapeamentos com o Hibernate.
É um mapeamento simples:
Classe Usuario:
@OneToMany(targetEntity = Direito.class, mappedBy = "id.usuario", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "codigoUsuario", referencedColumnName = "codigoUsuario")
private Set<Direito> direitos;
Classe com os direitos do usuário
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "codigoUsuario", referencedColumnName="codigoUsuario")
private Usuario usuario;
Não alterei as entidade, mas está disparando a seguinte exception:
Caused by: org.hibernate.AnnotationException: Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn: com.domain.entity.cfg.Usuario.direitos
at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:484)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1931)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3431)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3385)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1337)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1727)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1778)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:242)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:372)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:357)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
Alguém já passou por isso?