-
1. Re: Big Trouble!! Problem with finder methods.
davidjencks Oct 22, 2001 10:37 PM (in response to banigreyling)Just to check, do you have equals and hashcode implemented properly for your pk object? (same constructor values ==> pk1.equals(pk2) == true, and pk1.equals(pk2) ==> pk1.hashcode() == pk2.hashcode())
-
2. Re: Big Trouble!! Problem with finder methods.
banigreyling Oct 23, 2001 3:15 AM (in response to banigreyling)I waited for this question. This is my implementation. I cannot see any problem with it, but maybee all it need is another opinion, so here it is:
public int hashCode() {
return companyCode.hashCode() + accountNo.hashCode();
}
public boolean equals(Object obj) {
if (this.getClass().equals(obj.getClass())) {
AccountHolderPK that = (AccountHolderPK) obj;
return this.companyCode.equals(that.companyCode) && this.accountNo.equals(that.accountNo);
}
return false;
}
The following test:
AccountHolderPK pk1 = new AccountHolderPK("ABC","MYACCOUNT");
AccountHolderPK pk2 = new AccountHolderPK("ABC","MYACCOUNT");
System.out.println(pk1.equals(pk2));
System.out.println(pk2.equals(pk1));
System.out.println(pk1.hashCode() == pk2.hashCode());
yields the output
true
true
true
So I think this implementation is OK. Any other suggetions?
Regards
Bani -
3. Re: Big Trouble!! Problem with finder methods.
banigreyling Nov 1, 2001 8:25 AM (in response to banigreyling)Anyone? .... Please!!
-
4. Re: Big Trouble!! Problem with finder methods.
danch1 Nov 1, 2001 2:54 PM (in response to banigreyling)Just out of curiosity, are you using commit-option A? This is the default.
If so, can you try commit-option B (change standardjboss.xml) and see if that helps, and post on this topic if it does?
Believe it or not, this will help narrow down this problem and (possibly) another. -
5. Re: Big Trouble!! Problem with finder methods.
banigreyling Nov 2, 2001 3:31 AM (in response to banigreyling)I had no doubt that this would be a good workaround. Just to make sure I tested it and yes, with commit option B the problem seems to disapear. What actually is happenning, is the stale object get updated before participating in the request and therefore the problem is not visible.
There is not supposed to be a stale object. Seems like JBoss keeps a seperate cache for each finder method. -
6. Re: Big Trouble!! Problem with finder methods.
danch1 Nov 2, 2001 3:33 PM (in response to banigreyling)commit option B _means_ that any entity bean is updated from storage before participating in a transaction. This isn't 'hiding' the bug so much as downright avoiding it!
Last question: are you using read-ahead?
I'm already hunting this bug, so any information you can give me will help me find it.
thanks,
danch -
7. Re: Big Trouble!! Problem with finder methods.
banigreyling Nov 4, 2001 12:36 AM (in response to banigreyling)Danch
No, I am not using Read-Ahead. I am using tuned updates though.
Thanks a lot
Bani
PS could you maybe have a look at http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ and make an informed comment. I am flying a bit in the dark there. -
8. Big Trouble!! Problem with finder methods.
banigreyling Nov 15, 2001 7:04 AM (in response to banigreyling)Any more news on this front?
-
9. Re: Big Trouble!! Problem with finder methods.
danch1 Nov 15, 2001 3:14 PM (in response to banigreyling)Sorry about the delay. I'm trying to replicate this problem and I'm having trouble. Can you send me your deployment descriptors ('sanitized' to hide details of your application, if you like) via email (danch@danch.com)?
Also, is the code sample in your original post from a client (or servlet/JSP), or is it in a session bean?
thanks,
danch -
10. Re: Big Trouble!! Problem with finder methods.
banigreyling Nov 16, 2001 4:45 AM (in response to banigreyling)Hi Danch
I got the source of the problem. Sorry, I should have picked this up earlier.
If I create a Primary Key object to lookup some object, all is fine. When I do a findBySomeColumn, then the container creates the primary key: all should still be fine, BUT I am using CHAR datatypes. SQLServer rightpad the data in the PK with spaces. As a result the objects evaluates to not being equal. The Question that now remain is: Should the container trim the string values, or should equality be simulated by the PrimaryKey object's equals method? I think the latter option is more practical, as someone might want the spaces. Maybe a deployment option to trim string values?
Thanks
Bani -
11. Re: Big Trouble!! Problem with finder methods.
danch1 Nov 16, 2001 1:57 PM (in response to banigreyling)Glad to hear you've found the problem. I agree, the PrimaryKey needs to do the trimming: as you say, the spaces may be important.