jokacwb 24 de mai. de 2011
Vamus Lá
Sempre que postar código coloque entre a tag Code, recomendo editar seu post e corrigir isso;
Passe qual a mensagem de erro que vc obteve;
Eu não tenho certeza mas acho q ta sobrando @id ;
Como vc está usando jpa, acredito que não seja problema com algum xml;
Neste site http://www.java2s.com/Code/Java/JPA/OneToManyAndManyToOneMapping.htm tem uns exemplos bons de relacionamento
É isso
andreReisLima 25 de mai. de 2011
olha o erro que dá…
Exception in thread “ AWT - EventQueue - 0 ” javax . persistence . PersistenceException : [ PersistenceUnit: orcamentoPU ] Unable to configure EntityManagerFactory
at org . hibernate . ejb . Ejb3Configuration . configure ( Ejb3Configuration . java : 265 )
at org . hibernate . ejb . HibernatePersistence . createEntityManagerFactory ( HibernatePersistence . java : 125 )
at javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 51 )
at javax . persistence . Persistence . createEntityManagerFactory ( Persistence . java : 33 )
at orcamento . Conectar . getsession ( Conectar . java : 24 )
at orcamento . Consultas .( Consultas . java : 28 )
at orcamento . inicioJF .( inicioJF . java : 349 )
at orcamento . inicioJF $ 25. run ( inicioJF . java : 905 )
at java . awt . event . InvocationEvent . dispatch ( InvocationEvent . java : 209 )
at java . awt . EventQueue . dispatchEvent ( EventQueue . java : 597 )
at java . awt . EventDispatchThread . pumpOneEventForFilters ( EventDispatchThread . java : 269 )
at java . awt . EventDispatchThread . pumpEventsForFilter ( EventDispatchThread . java : 184 )
at java . awt . EventDispatchThread . pumpEventsForHierarchy ( EventDispatchThread . java : 174 )
at java . awt . EventDispatchThread . pumpEvents ( EventDispatchThread . java : 169 )
at java . awt . EventDispatchThread . pumpEvents ( EventDispatchThread . java : 161 )
at java . awt . EventDispatchThread . run ( EventDispatchThread . java : 122 )
Caused by : org . hibernate . AnnotationException : Illegal attempt to map a non collection as a @OneToMany , @ManyToMany or @CollectionOfElements : tabelas . TbrjCadContas . codConta
at org . hibernate . cfg . annotations . CollectionBinder . getCollectionBinder ( CollectionBinder . java : 264 )
at org . hibernate . cfg . AnnotationBinder . processElementAnnotations ( AnnotationBinder . java : 1455 )
at org . hibernate . cfg . AnnotationBinder . bindClass ( AnnotationBinder . java : 754 )
at org . hibernate . cfg . AnnotationConfiguration . processArtifactsOfType ( AnnotationConfiguration . java : 534 )
at org . hibernate . cfg . AnnotationConfiguration . secondPassCompile ( AnnotationConfiguration . java : 286 )
at org . hibernate . cfg . Configuration . buildMappings ( Configuration . java : 1115 )
at org . hibernate . ejb . Ejb3Configuration . buildMappings ( Ejb3Configuration . java : 1225 )
at org . hibernate . ejb . EventListenerConfigurator . configure ( EventListenerConfigurator . java : 159 )
at org . hibernate . ejb . Ejb3Configuration . configure ( Ejb3Configuration . java : 854 )
at org . hibernate . ejb . Ejb3Configuration . configure ( Ejb3Configuration . java : 191 )
at org . hibernate . ejb . Ejb3Configuration . configure ( Ejb3Configuration . java : 253 )
jokacwb 25 de mai. de 2011
Achei a resposta para o seu problema aqui mesmo no forum, de uma lida
neste post http://www.guj.com.br/java/72190-erro-com-as-anotacoes
ele deve resolver,
Outra coisa a anotação @id server para definir o campo que corresponde a chave primaria do seu objeto
e vc ta anotando com @id os campos codConta e fornecedor, acredito que nao seja nenhum deles , avalie com carinho isso
e anote somente o campo de ConsOrcamento que realmente representa a chave primaria
da tabela ConsOrcamento.
Efetue os ajustes necessários e post o resultado.