-->
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.  [ 3 posts ] 
Author Message
 Post subject: odd error -- enumerations not equal after load from db?
PostPosted: Thu Oct 26, 2006 6:01 pm 
Newbie

Joined: Mon Jul 03, 2006 4:28 pm
Posts: 15
v3.2GA (RC also)

Has anyone hit a problem where they persist an entity that contains an @Enumerated enumeration in one session, load it back in another, and do an equality test (== and .equals(...)) that returns false.

I have an enumeration Choice { YES, NO }; and a class Opinion that contains

@Enumerated
Choice choice;

...when I compare it to what I _know_ it is, it gives me a false, so with the below snippet

Choice myChoice= Choice.YES;
log.debug("Testing to see if opinion choice " + op.getChoice() + " is " + myChoice);
if(op.getChoice() == myChoice) {
log.debug("The choices are equal");
}else{
if(log.isDebugEnabled()){
log.debug("The choices are not equal.");
log.debug("Supplied choice has hashcode " + myChoice.hashCode());
log.debug("Opinion choice has hashcode " + op.getChoice().hashCode());
}
}


I get the following output from the above logging code:

Testing to see if opinion choice YES is YES
The choices are not equal.
Supplied choice has hashcode 19756588
Opinion choice has hashcode 26890590

This is the same for == and .equals(...).

I'm sure I'm just doing something naff here....has anyone come across this before?

Cheers
Adam


Top
 Profile  
 
 Post subject: it's a bug in the VM
PostPosted: Fri Oct 27, 2006 11:37 pm 
Newbie

Joined: Mon Jul 03, 2006 4:28 pm
Posts: 15
I failed to mention that my hibernate code was in an ejb, and the call was coming remotely (RMI) from the web layer. Currently you can't pass enums over RMI and expect them to work properly.

It's being worked on by sun http://bugs.sun.com/bugdatabase/view_bu ... id=6277781

pretty big overlook on suns part....the network is the computer, look we have enums now too.....oh :(


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 6:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
nasty.
If you change the protocol that might work though

_________________
Emmanuel


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