Erro emitido pelo Hibernate

Olá a todos!

Será que alguém poderia me dizer o significado desse erro?. Quebrei a cabeça para achar sobre esse erro, usei o Google, a busca aqui do GUJ, e não consegui descobrir!!!


16:15:36,185org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
	at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:56)
	at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
	at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
	at $javaBeans.Especie$$EnhancerByCGLIB$$417e7a05.toString(<generated>)
	at javax.swing.table.DefaultTableCellRenderer.setValue(Unknown Source)
	at javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent(Unknown Source)
	at javax.swing.JTable.prepareRenderer(Unknown Source)
	at com.birosoft.liquid.LiquidTableUI.paintCell(LiquidTableUI.java:298)
	at com.birosoft.liquid.LiquidTableUI.paintCells(LiquidTableUI.java:190)
	at com.birosoft.liquid.LiquidTableUI.paint(LiquidTableUI.java:101)
	at javax.swing.plaf.ComponentUI.update(Unknown Source)
	at javax.swing.JComponent.paintComponent(Unknown Source)
	at javax.swing.JComponent.paintToOffscreen(Unknown Source)
	at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
	at javax.swing.RepaintManager.paint(Unknown Source)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintForceDoubleBuffered(Unknown Source)
	at javax.swing.JViewport.blitDoubleBuffered(Unknown Source)
	at javax.swing.JViewport.windowBlitPaint(Unknown Source)
	at javax.swing.JViewport.setViewPosition(Unknown Source)
	at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.hsbStateChanged(Unknown Source)
	at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(Unknown Source)
	at javax.swing.DefaultBoundedRangeModel.fireStateChanged(Unknown Source)
	at javax.swing.DefaultBoundedRangeModel.setRangeProperties(Unknown Source)
	at javax.swing.DefaultBoundedRangeModel.setValue(Unknown Source)
	at javax.swing.JScrollBar.setValue(Unknown Source)
	at javax.swing.plaf.basic.BasicScrollBarUI$TrackListener.setValueFrom(Unknown Source)
	at javax.swing.plaf.basic.BasicScrollBarUI$TrackListener.mouseDragged(Unknown Source)
	at com.birosoft.liquid.LiquidScrollBarUI$MyTrackListener.mouseDragged(LiquidScrollBarUI.java:432)
	at java.awt.Component.processMouseMotionEvent(Unknown Source)
	at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

Obrigada!!!

Patty

basicamente eh assim: vc pegou um objeto no banco que tem alguma propriedade (campo) persistida tambem pelo hibernate, mas esta setado como lazy;
dai vc fechou a sessao sem precisar desse campo e, com a sessao fechada, vc tentou acessar o campo, mas como ele era “lazy”, ele tenta acessar o banco para efetivamente pegar os valores, porem a sessao esta fechada e ele nao sabe o que fazer, entao lanca uma excecao…

Olá Takeshi10,

O ‘lazy’ é padrão do Hibernate?..porque minhas propriedades não estão setadas como ‘lazy’…

Patty

Olá!

Todas as associações são “lazy” por default.

[]'s

Olá!!

Obrigada!!!

Patty

lembrando que, geralmente, eh uma boa ideia as associacoes serem ‘lazy’ (principalmente as colecoes)…
no mais, faça o “fetch” das coisas que vc precisa antes de fechar a sessao…
por exemplo, num ambiente web, eh comum vc fechar a sessao somente ao final do request com, por exemplo, um filtro…