-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Fields not retrieved on Lazy Fetching+OpenSessionInView+JSF
PostPosted: Thu Nov 30, 2006 10:30 am 
Newbie

Joined: Thu Nov 30, 2006 9:48 am
Posts: 1
General cenario:
Lazy + Open Session in View filter pattern + Request scope + JSF


I have a cenario where there are many large and composed objects (many-to-one, one-to-many, many-to-many and so on). So i need hibernate lazy fetching to avoid memory overcharge on collections retrieval. In all the cases, those collections are retrieved by some DAO, on methods like:


Code:
public Collection <LCR> getAll() throws ExceptionDAO {
      Session session = DAOHibernateFactory.getSession();
      try {         
         List<LCR> lcrs = session .createCriteria(LCR.class).list();   
         return lcrs;
      } catch (Exception e) {
                        //on except, rollback and recreate session
         DAOHibernateFactory.recreateHibernateSession();
         throw new ExceptionDAO (e.getMessage());
      }
   }


To present all LCR´s, im using JSF DataTable, but mysteriously, some fields are not showed when should be. Those fields, are exactly the fields that should be automatically retrieved by Hibernate on demand (what i understand that should be lazy fetching). When i change the hibernate mappings and put
Code:
lazy="false"
and
Code:
session.flush()
before
Code:
return lcrs;
, them it works (the correct sqls are executed and the fields are retrieved from underlying classes) .

What is wrong? Im thinking wrong about Lazy fetching?


Hibernate version:
3.2.1.ga
Mapping documents:
Relevant fields:
Hibernate.cfg

Code:
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>     
<property name="current_session_context_class">thread</property>         


Name and version of the database you are using:
HSQLDB


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.