Looked in template for pk from 1.2b2 that hashCode() is used in the same way as in the old ejbdoclet that we still use. We recently had a problem with this implementation.

Hashcode is initiated to Integer.MIN_VALUE and calculated only if the cached hashcode is equal to Integer.MIN_VALUE. And that works ok as long as the PK stays within a JVM. We had a situation where this didn't work that well. JBoss uses the PK as a key in internal entity caches. We had a situation where a PK was sent within a bigger dataobject to a client JVM. There some entity fields where changed and then sent back to the server. What happened during the deserialization was that the transient hashcode was initiated to 0 and hence never recalculated since it differed from Integer.MIN_VALUE. Back on the server a findByPrimaryKey was issued using this 'incorrect' PK which resulted in a load from database and a second instance of the same entity in cache.

We solved this in our ejbdoclet by changing hashcode to be initiated to 0 instead of Integer.MIN_VALUE. Could also be done by extending the check if hashcode should be calculated to include test if it is 0.

Whats your oppinion about this? I think the change should be implemented in current codebase.

/Lennart



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to