0

Hibernate lazy initialization exception caused by ZK listitem

asked 2009-03-27 04:11:57 +0800

adrianlim83 gravatar image adrianlim83
69 1 2

updated 2009-03-27 04:13:18 +0800

Hi everyone, correct me if my perception is wrong.

I am currently trace into the system to identify how the spring + zk + hibernate causing lazy initialization exception although we include OpenSessionInView listener and TransactionSynchronizationManagement in zk.xml and web.xml. The problem i found is causes by the number of query called. For instance, I have 22 records in the list item, however, it will only called up to 20 records, where the 2 records will be called later. When we set the lazy=true, this is how the lazy initialization exception being thrown.

The way to solve this is by setting the lazy=false, however, this is not a good practice. I have try with a lot of way, but is not helpful. First of all, I try to use EntityManager to merge the bean, however, because of my existing architecture is using spring to manage the session factory by HibernateDaoSupport, therefore, the entity name is required every time i make a called to the db. Because of this, i use SpringUtil to inject the session factory from the application context, and, this time it work but is not help in the current problem (base on my explanation in above sentence).

Is there anyone has a better solutions towards this issue? Your help and concerned is highly appreciated and thanks for taking time to read up this content

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2009-04-02 02:23:10 +0800

PeterKuo gravatar image PeterKuo
481 2

Close this thread to other hibernate related thread.this

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-03-27 04:11:57 +0800

Seen: 361 times

Last updated: Apr 02 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More