-->
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: Problem with eager queries?
PostPosted: Mon Jan 10, 2005 4:09 pm 
Beginner
Beginner

Joined: Sun Nov 07, 2004 4:19 pm
Posts: 38
[b]Hibernate version:[/b]

2.1.6


I have to use psuedo code to express my problem since I'm using spring and our own framework.

I've set the hibernate property hibernate.cache.use_query_cache to true.

I've set the setCacheable to true for Criteria object for me get and getEager routines.

Here is my calling code. The only difference between getEager and get is that for getEager we use criteria.setFetchMode("address", FetchMode.EAGER);


startTransaction();

Prospect prospect =
prospectDao.get(userSession, prospectDAOTest.getExistingId());

Prospect prospect2 = prospectDao.getEager(userSession, prospectDAOTest.getExistingId(), "address");

commitTransaction();

prospect2.getAddress().toString() // throws Could not initialize proxy - the owning Session session

SEVERE: Exception initializing proxy
net.sf.hibernate.HibernateException: Could not initialize proxy - the owning Session was closed
at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:47)
at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:60)
at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:164)
at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108)
at fivesquare.common.data.model.crm.Address$$EnhancerByCGLIB$$586aa3af.toString(<generated>)
at fivesquare.common.data.dao.impl.BaseHibernateDAOTest.testCaching2(BaseHibernateDAOTest.java:74)

This is what I think is happening. The first retrieval of my prospect record doesn't include the fetching of the address. My second retrieve of the prospect record retrieves the cached result and ignores the fetch portion of the cached query. Thus the address object doesn't get initialized.

Is this a bug or an unfortuate side affect of caching results in the session?

Dino


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.