tiagowmm 7 de dez. de 2009
tentei da seguinte forma:
@CollectionOfElements ( fetch = FetchType . LAZY , targetElement = TipoPerfil . class )
@JoinTable ( name = "colUsuarioscadPerfis" , joinColumns = @JoinColumn ( name = "NUMG_Usuario" , referencedColumnName = "id" ) , inverseJoinColumns = { @JoinColumn ( name = "NUMG_Perfil" ) } )
public List < TipoPerfil > getListaPerfil () {
return listaPerfil ;
}
apresenta o seguinte erro:
Caused by : org . hibernate . AnnotationException : Use of @JoinTable . inverseJoinColumns targeting an unmapped class : Usuario . listaPerfil [ TipoPerfil ]
at org . hibernate . cfg . annotations . CollectionBinder . bindManyToManySecondPass ( CollectionBinder . java : 1087 )
at org . hibernate . cfg . annotations . CollectionBinder . bindStarToManySecondPass ( CollectionBinder . java : 602 )
at org . hibernate . cfg . annotations . CollectionBinder $ 1. secondPass ( CollectionBinder . java : 543 )
at org . hibernate . cfg . CollectionSecondPass . doSecondPass ( CollectionSecondPass . java : 66 )
at org . hibernate . cfg . Configuration . secondPassCompile ( Configuration . java : 1163 )
at org . hibernate . cfg . AnnotationConfiguration . secondPassCompile ( AnnotationConfiguration . java : 329 )
at org . hibernate . cfg . Configuration . buildMappings ( Configuration . java : 1148 )
at org . springframework . orm . hibernate3 . LocalSessionFactoryBean . buildSessionFactory ( LocalSessionFactoryBean . java : 673 )
at org . springframework . orm . hibernate3 . AbstractSessionFactoryBean . afterPropertiesSet ( AbstractSessionFactoryBean . java : 211 )
at org . springframework . beans . factory . support . AbstractAutowireCapableBeanFactory . invokeInitMethods ( AbstractAutowireCapableBeanFactory . java : 1369 )
at org . springframework . beans . factory . support . AbstractAutowireCapableBeanFactory . initializeBean ( AbstractAutowireCapableBeanFactory . java : 1335 )
… 172 more
07 / 12 / 2009 15 : 38 : 05 org . apache . catalina . core . StandardContext start
tiagowmm 8 de dez. de 2009
Resolvi da sequinte forma:
@CollectionOfElements
@JoinTable( name="nome_da_tabela", joinColumns={@JoinColumn(name="NUMG_Usuario")} )
@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@Type(type = "org.hibernate.usertype.TipoPerfilUser")
@Column( name="NUMG_Perfil")
public List<TipoPerfil> getListaPerfil() {
if (listaPerfil == null) {
listaPerfil = new ArrayList<TipoPerfil>();
}
return listaPerfil;
}
mais sobre o assunto: