zepunk 31 de jul. de 2006
opa…
Coloque as anotações nos getters, e para fazer o auto-incremento user a annotatios @GeneratedValue
@Id
@GeneratedValue
public Long getId () {
return id ;
}
abraços…
vskuroda 14 de ago. de 2006
Opa obrigado pela dica onde o meu get ficou assim:
@Id
@GeneratedValue
public Double getUsuarioSamID ( Double usuarioSamID ) {
return usuarioSamID ;
}
Porem está dando erro. Será que é por causa da minha classe de login ser o mesmo do cadastro???
Vou debugar e ver o porque. Estranho que teoricamente era para dar certo. Mas se vc tiver outra dica eu agradeço.
Atenciosamente Valter
zepunk 14 de ago. de 2006
Posta o erro para agente saber o que esta acontecendo.
vskuroda 14 de ago. de 2006
Segue ai o erro, porem o meu Filter tb não esta deixando passar, Estranho que quando coloco o ID na mão ele Chega a cadastrar o usuario e grava no Banco:
11 : 52 : 40 , 718 ERROR InvokeApplicationPhase : 80 - # { validausuario . validar } : javax . faces . el . EvaluationException : java . lang . ExceptionInInitializerError
javax . faces . FacesException : # { validausuario . validar } : javax . faces . el . EvaluationException : java . lang . ExceptionInInitializerError
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 78 )
at javax . faces . component . UICommand . broadcast ( UICommand . java : 312 )
at javax . faces . component . UIViewRoot . broadcastEvents ( UIViewRoot . java : 267 )
at javax . faces . component . UIViewRoot . processApplication ( UIViewRoot . java : 381 )
at com . sun . faces . lifecycle . InvokeApplicationPhase . execute ( InvokeApplicationPhase . java : 75 )
at com . sun . faces . lifecycle . LifecycleImpl . phase ( LifecycleImpl . java : 200 )
at com . sun . faces . lifecycle . LifecycleImpl . execute ( LifecycleImpl . java : 90 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 197 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 252 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 173 )
at util . FilterLog . doFilter ( FilterLog . java : 36 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 202 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 173 )
at org . netbeans . modules . web . monitor . server . MonitorFilter . doFilter ( MonitorFilter . java : 362 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 202 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 173 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 213 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 178 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 126 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 105 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 107 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 148 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 856 )
at org . apache . coyote . http11 . Http11Protocol$Http11ConnectionHandler . processConnection ( Http11Protocol . java : 744 )
at org . apache . tomcat . util . net . PoolTcpEndpoint . processSocket ( PoolTcpEndpoint . java : 527 )
at org . apache . tomcat . util . net . LeaderFollowerWorkerThread . runIt ( LeaderFollowerWorkerThread . java : 80 )
at org . apache . tomcat . util . threads . ThreadPool$ControlRunnable . run ( ThreadPool . java : 684 )
at java . lang . Thread . run ( Thread . java : 595 )
Caused by : javax . faces . el . EvaluationException : java . lang . ExceptionInInitializerError
at com . sun . faces . el . MethodBindingImpl . invoke ( MethodBindingImpl . java : 130 )
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 72 )
… 27 more
Caused by : java . lang . ExceptionInInitializerError
at hb . HibernateUtil .( HibernateUtil . java : 24 )
at classes . ValidaUsuario . validar ( ValidaUsuario . java : 19 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( NativeMethodAccessorImpl . java : 39 )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( DelegatingMethodAccessorImpl . java : 25 )
at java . lang . reflect . Method . invoke ( Method . java : 585 )
at com . sun . faces . el . MethodBindingImpl . invoke ( MethodBindingImpl . java : 126 )
… 28 more
Caused by : org . hibernate . AnnotationException : No identifier specified for entity : classes . Usuario_Sam
at org . hibernate . cfg . AnnotationBinder . bindClass ( AnnotationBinder . java : 619 )
at org . hibernate . cfg . AnnotationConfiguration . processArtifactsOfType ( AnnotationConfiguration . java : 353 )
at org . hibernate . cfg . AnnotationConfiguration . secondPassCompile ( AnnotationConfiguration . java : 265 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1205 )
at hb . HibernateUtil .( HibernateUtil . java : 17 )
… 34 more
11 : 52 : 40 , 843 ERROR [ Faces Servlet ] : 253 - Servlet . service () for servlet Faces Servlet threw exception
javax . faces . FacesException : # { validausuario . validar } : javax . faces . el . EvaluationException : java . lang . ExceptionInInitializerError
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 78 )
at javax . faces . component . UICommand . broadcast ( UICommand . java : 312 )
at javax . faces . component . UIViewRoot . broadcastEvents ( UIViewRoot . java : 267 )
at javax . faces . component . UIViewRoot . processApplication ( UIViewRoot . java : 381 )
at com . sun . faces . lifecycle . InvokeApplicationPhase . execute ( InvokeApplicationPhase . java : 75 )
at com . sun . faces . lifecycle . LifecycleImpl . phase ( LifecycleImpl . java : 200 )
at com . sun . faces . lifecycle . LifecycleImpl . execute ( LifecycleImpl . java : 90 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 197 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 252 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 173 )
at util . FilterLog . doFilter ( FilterLog . java : 36 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 202 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 173 )
at org . netbeans . modules . web . monitor . server . MonitorFilter . doFilter ( MonitorFilter . java : 362 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 202 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 173 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 213 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 178 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 126 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 105 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 107 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 148 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 856 )
at org . apache . coyote . http11 . Http11Protocol$Http11ConnectionHandler . processConnection ( Http11Protocol . java : 744 )
at org . apache . tomcat . util . net . PoolTcpEndpoint . processSocket ( PoolTcpEndpoint . java : 527 )
at org . apache . tomcat . util . net . LeaderFollowerWorkerThread . runIt ( LeaderFollowerWorkerThread . java : 80 )
at org . apache . tomcat . util . threads . ThreadPool$ControlRunnable . run ( ThreadPool . java : 684 )
at java . lang . Thread . run ( Thread . java : 595 )
Caused by : javax . faces . el . EvaluationException : java . lang . ExceptionInInitializerError
at com . sun . faces . el . MethodBindingImpl . invoke ( MethodBindingImpl . java : 130 )
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 72 )
… 27 more
Caused by : java . lang . ExceptionInInitializerError
at hb . HibernateUtil .( HibernateUtil . java : 24 )
at classes . ValidaUsuario . validar ( ValidaUsuario . java : 19 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( NativeMethodAccessorImpl . java : 39 )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( DelegatingMethodAccessorImpl . java : 25 )
at java . lang . reflect . Method . invoke ( Method . java : 585 )
at com . sun . faces . el . MethodBindingImpl . invoke ( MethodBindingImpl . java : 126 )
… 28 more
Caused by : org . hibernate . AnnotationException : No identifier specified for entity : classes . Usuario_Sam
at org . hibernate . cfg . AnnotationBinder . bindClass ( AnnotationBinder . java : 619 )
at org . hibernate . cfg . AnnotationConfiguration . processArtifactsOfType ( AnnotationConfiguration . java : 353 )
at org . hibernate . cfg . AnnotationConfiguration . secondPassCompile ( AnnotationConfiguration . java : 265 )
at org . hibernate . cfg . Configuration . buildSessionFactory ( Configuration . java : 1205 )
at hb . HibernateUtil .( HibernateUtil . java : 17 )
… 34 more
Atenciosamente Valter
vskuroda 16 de ago. de 2006
E ai pessoal ainda o meu auto incrementão não funciona. Esta dando que tenho que atribuir um valor do id antes de eu gravar. A mensagem eh essa: ’ ids for this class must be manually assigned before calling save".
Se alguem tiver alguma ideia de como posso fazer isso eu agradeço . Ja usei :
@Id
@GeneratedValue
public Double getUsuarioSamID ( Double usuarioSamID ) {
return usuarioSamID ;
}
mas não esta dando certo.
atenciosamente Valter
mederafael 20 de out. de 2006
@Table (name =“Usuario_Sam”)
será que vc naum precisa passar o nome do schema do banco antes da tabela… tive um problema parecido com o postgres
resulvi assim!!
schema.banco
schema.sequence…
Thiago_Senna 20 de out. de 2006
Vocês precisam dar uma olhada na estratégia que o banco usa para gerar os ID’s, e isso deve ser passado para a annotation GeneratedValue. Os tipos disponíveis são TABLE, IDENTITY, SEQUENCE ou AUTO (default). Testem estas opções para ver se funfa.
vskuroda 15 de nov. de 2006
Vocês precisam dar uma olhada na estratégia que o banco usa para gerar os ID’s, e isso deve ser passado para a annotation GeneratedValue. Os tipos disponíveis são TABLE, IDENTITY, SEQUENCE ou AUTO (default). Testem estas opções para ver se funfa.
Ai pessoal no Banco coloquei um sequencial ai deu tudo certo… obrigado pelas dicas…
jason_bourne 21 de nov. de 2007
qual é o import q devo dar pra usar o @GeneratedValue ?