-->
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.  [ 11 posts ] 
Author Message
 Post subject: 3.0.5 to 3.1.1 migration: problem with many-to-one lazy
PostPosted: Fri Jan 27, 2006 10:47 am 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Hi All,

I'm trying to upgrade from hibernate-3.0.5 to hibernate-3.1.1 and my application's regression tests have caught a problem with lazily loaded many-to-one associations.

In Hibernate-3.0.5, I had the following mapping fragment.

Code:
<many-to-one name="customer" column="PRIMARY_KEY_COLUMN" unique="true" lazy="true" fetch="select" insert="false" update="false"/>


I *am* doing the necessary build-time instrumentation and with hibernate-3.0.5 "customer" is not loaded when loading the associated entity through an HQL query.
(The HQL query specifies no eager fetching of the customer association.)

For Hibernate-3.1.1, I applied the following change (i.e. lazy="true" --> lazy="no-proxy"):

Code:
<many-to-one name="customer" column="PRIMARY_KEY_COLUMN" unique="true" lazy="no-proxy" fetch="select" insert="false" update="false"/>


Now "customer" is always being loaded when executing the query.

Is this a hibernate bug?
Or perhaps was my previous usage wrong and only working by chance?

I don't suppose there is a regression test in the Hibernate test suite for many-to-one unique lazy associations that someone could point me to?

If not, I'd be glad to write up a simple test case to reproduce this behaviour.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 10:57 am 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Just a quick follow-up... changing the loading from an HQL query to a simple Session.load yields the same (seemingly) buggy behaviour.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 12:04 pm 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
I've found a test case for many-to-one no-proxy, but it seems that the actual test code was commented out between hibernate-3.0.5 and hibernate-3.1.1.

org.hibernate.test.instrument.InstrumentTest line 160:

Code:
//assertFalse(Hibernate.isPropertyInitialized(doc, "owner"));


http://cvs.sourceforge.net/viewcvs.py/h ... 16&r2=1.17

If I uncomment the line and re-run the test, it fails.
This is equivalent to my own application's test failure.

So, it looks like this was a known issue at some point... are there any plans to address this regression?
I've already searched JIRA and didn't find anything related to this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 11:19 am 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
FYI, I've created a JIRA task for this issue:

http://opensource2.atlassian.com/projects/hibernate/browse/HHH-1435


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 10:36 am 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Hmm... still no replies either here or on JIRA.
Has nobody else encountered this issue?


Top
 Profile  
 
 Post subject: I'm not sure if this is the same problem, but.....
PostPosted: Fri Feb 17, 2006 3:40 am 
Newbie

Joined: Thu Jan 05, 2006 4:13 pm
Posts: 4
Frank,

I had what could be a similar problem.

I was getting a StackOverflowException with a large linked list of Items.

Code:
<many-to-one name="next" class="Item" cascade="none" column="nextItemID" lazy="proxy" outer-join="false" />
<many-to-one name="prev" class="Item" cascade="none" column="prevItemID" lazy="proxy" outer-join="false"/>


It looked like it was trying to load all of the objects, despite the lazy="proxy" After 500 or so, I'd get a StackOverflowException.

Today, we upgraded to Hibernate 3.2. That seems to have corrected the problem.

I hope this helps.

DougP


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 20, 2006 10:01 am 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Hi Doug,

Did you mean hibernate-3.1.2?
We did test with hibernate-3.1.2 and the problem remains. (at least with the no-proxy option)
I don't recall if I tested lazy="proxy" with 3.1.1 or 3.1.2.
If lazy="proxy" is working for you in 3.1.2, maybe I'll double check that option for us.

Thanks!


Top
 Profile  
 
 Post subject: Yup, that was 3.1.2
PostPosted: Mon Feb 20, 2006 4:57 pm 
Newbie

Joined: Thu Jan 05, 2006 4:13 pm
Posts: 4
Yes, it was Hibernate 3.1.2. I don't see in the bug list where it was fixed, but it appears to have helped up out.

Since I have it handy, here's the list of fixes in 3.1.2

Changes in version 3.1.2 (01.27.2006)

-------------------------------------------
** Bug
* [HHH-73] - Statistics for HQL queries use pre-processed query string
* [HHH-1306] - HQL parsing problem with join fetching of arrays/collections of values
* [HHH-1370] - Warning in hibernate-mapping-3.0.dtd
* [HHH-1371] - MappingException is thrown when the same column is referenced with different case
* [HHH-1386] - Numeric (long) literals not properly handled by HQL parser
* [HHH-1390] - Session.isOpen() throws exeception when the session is closed with ThreadLocalSessionContext
* [HHH-1391] - Invalid parameter index SQLException when using named parameters after positional parameters
* [HHH-1392] - Proxies cannot be serialized after session is closed
* [HHH-1398] - extends and entity-names broken with mapping-level package attribute
* [HHH-1407] - return-join broken for entity collections

** Improvement

* [HHH-1364] - Defensive check of isClosed when obtaining a connection from ConnectionManager
* [HHH-1367] - warn level log "this operation breaks ==" may be disturbing

** New Feature
* [HHH-1372] - Support for MySQL5 new varchar length

** Patch
* [HHH-1005] - Criteria LEFT JOIN capability when adding Order to associations

** Task
* [HHH-1373] - Document update versioned


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 3:32 pm 
Beginner
Beginner

Joined: Tue Jun 07, 2005 11:36 pm
Posts: 22
For anyone else who discovers this thread in the future - another caveat that I just figured out after pounding my head on the same issue is that if you have default-lazy="true" set on the class which is the single-end of a many-to-one association, the lazy settings for the association will be ignored and the whole object will be loaded when the object at the multi-end is loaded. This is with 3.1.2, at least.

It makes sense now that I realize it. It would be nice if there was a caveat to this affect in section 19.1 of the (usually great) manual.

_________________
Useful? Hit me with a point! Completely off base? Ya, well, what do you expect from a newbie...


Top
 Profile  
 
 Post subject: laziness
PostPosted: Mon Mar 13, 2006 1:09 am 
Newbie

Joined: Thu Aug 04, 2005 12:45 pm
Posts: 4
I have been trying to figure this one out, and your comment really helps!

So I have a one-to-many and the many side class has lazy="false". This forces the lazy one side to load the many side using a subsequent select.

Why is this? I've tested against the latest code in the head.


Top
 Profile  
 
 Post subject: 3.2.6 ga still has issue
PostPosted: Fri Sep 19, 2008 8:40 am 
Newbie

Joined: Thu Nov 02, 2006 8:26 pm
Posts: 6
I cannot believe that this issue is still not resolved in 3.2.6 ga


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

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.