-->
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.  [ 12 posts ] 
Author Message
 Post subject: hibernate-3.0.2 broke EntityType.loadByUniqueKey?
PostPosted: Wed Apr 27, 2005 2:17 pm 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
I think I may have found a bug introduced in 3.0.2.
My application's regression tests are failing with 3.0.2 even though they pass on 3.0.1.

I think I tracked down the problem to the following change:

http://cvs.sourceforge.net/viewcvs.py/h ... 42&r2=1.43

Shouldn't loadByUniqueKey contain the following?

Object result = persistenceContext.getEntity(euk);
if ( result==null ) {
result = persister.loadByUniqueKey(uniqueKeyPropertyName, key, session);
}

Let me know if I need to create a JIRA issue and/or submit a test case for this.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 2:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Shit, you're right. I commented too much.

Damn, obviously there is a hole in the test suite!

Would you please create a patch to our test suite to reproduce this? We have plenty of existing property-ref examples.

That would be a great help, thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 2:48 pm 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Ok, I'll see what I can do about creating the test-case.
Meanwhile, it can still be fixed in CVS, right?
Wouldn't want other users to have to wait for my newbie self to get a proper test-case together, now would we? :-)

P.S. Thanks for the prompt reply!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 2:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
of course, i already fixed it

but, a fix without a test is a non-fix


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 5:09 pm 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Do your test-cases have a mechanism for evaluating the number of SQLs executed on a particular load operation?
I ran the org.hibernate.test.propertyref.PropertyRefTest with and without the bug, and here are the results of "s.get(Person.class, p.getId() )" for each:

//correct (one SQL)
Hibernate: select person0_.id as id1_, person0_.name as name0_1_, person0_.userId as userId0_1_, case when person0_1_.id is not null then 1 when person0_.id is not null then 0 end as clazz_1_, address1_.id as id0_, address1_.address as address1_0_, address1_.zip as zip1_0_, address1_.country as country1_0_, address1_.person as person1_0_ from Person person0_ left outer join Employee person0_1_ on person0_.id=person0_1_.id left outer join Address address1_ on person0_.id=address1_.person where person0_.id=?

//bug (duplicate/unnecessary DB fetch)
Hibernate: select person0_.id as id1_, person0_.name as name0_1_, person0_.userId as userId0_1_, case when person0_1_.id is not null then 1 when person0_.id is not null then 0 end as clazz_1_, address1_.id as id0_, address1_.address as address1_0_, address1_.zip as zip1_0_, address1_.country as country1_0_, address1_.person as person1_0_ from Person person0_ left outer join Employee person0_1_ on person0_.id=person0_1_.id left outer join Address address1_ on person0_.id=address1_.person where person0_.id=?

Hibernate: select address0_.id as id0_, address0_.address as address1_0_, address0_.zip as zip1_0_, address0_.country as country1_0_, address0_.person as person1_0_ from Address address0_ where address0_.person=?

Also, it turns out that my own application regression test failure was due to the second fetch of the associated object not returning any rows due to a problem with my test data/mappings.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 5:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yes, we can use Statistics to see any fetches that happen.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 11:05 am 
Regular
Regular

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

It pains me to be the bearer of so much bad news, but in trying to write up a test case for this issue, it looks like I stumbled onto another bug introduced in 3.0.2.

The newly added StatisticsImpl prepareStatementCount and closeStatementCount aren't being reset to 0 in the clear() method:

http://cvs.sourceforge.net/viewcvs.py/h ... 11&r2=1.12

On the bright side, I think I'm on my way to completing a test case for the propertyRef regression... should a Jira task be created so I can name the test method with the Jira reference number? Or should I just add a javadoc comment explaining what the test is for?

Note: I was thinking of adding a seperate test method to org.hibernate.test.propertyref.PropertyRefTest... is that the right place for it?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 11:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Thanks, fixed in CVS.

Yes, please add to JIRA.

And yes, that sounds like the right place :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 11:27 am 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Should a JIRA bug for the EntityType.loadByUniqueKey() regression be created so that the testcase can reference its number?
Or should I simply create a patch with a description of the bug and have the testcase reference that number instead?

Sorry, kinda new to JIRA and not sure what your procedures are...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 11:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
For the bug :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 11:38 am 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Ok, here's the JIRA issue:

http://opensource.atlassian.com/project ... se/HHH-414

I'll submit the modified org.hibernate.test.propertyref.PropertyRefTest once I'm done with it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 12:00 pm 
Regular
Regular

Joined: Tue Mar 22, 2005 2:27 am
Posts: 62
Ok, I think I've got the regression test completed and have attached it to the JIRA issue.
Please have a look and let me know if looks alright.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 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.