Jboss5 entity bean version 2. new instance return on each get
au lai seong
Greenhorn
Joined: Mar 06, 2011
Posts: 14
posted
0
Migration from Jboss4 to Jboss5 causes entity bean return new object instance.
The following 2 lines return different hash code. This only happen in jboss5. Any configuration for this?
entityBeanHomeObject.getAccount().hashCode();
entityBeanHomeObject.getAccount().hashCode();
I have noticed a similar phenomenon in a completely different situation. It appears that an object's position in the heap might influence the resulting hash value (that is my guess, I didn't pursue the details, so I cannot say for certain). You might have to write your own hashCode method for the account object to get the values to be consistent.
Hashcode is to check whether it is same object instance only. I want to get back the same instance. because i will use entityBeanHomeObject.getAccount().setName('A').
entityBeanHomeObject.getAccount().setName('A');
entityBeanHomeObject.getAccount().getName(); //i can not get back A here