File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Jboss5 entity bean version 2. new instance return on each get Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Jboss5 entity bean version 2. new instance return on each get" Watch "Jboss5 entity bean version 2. new instance return on each get" New topic
Author

Jboss5 entity bean version 2. new instance return on each get

au lai seong
Greenhorn

Joined: Mar 06, 2011
Posts: 14
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();
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

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.


JBoss In Action
au lai seong
Greenhorn

Joined: Mar 06, 2011
Posts: 14
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Jboss5 entity bean version 2. new instance return on each get