Thread:
 Possible mismatch 
 adamc   08 Mar 2005, 13:29 
 Re: Possible mismatch 
 magic   11 Mar 2005, 08:25 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: adamc (08 Mar 2005, 13:29) Replies: 1, Views: 36484
Subject: Possible mismatch
in the nullSafeGet() method you use

if (!resultSet.wasNull()) { 
    result = Enum.valueOf(clazz, name); 
}

Which works in terms of the <em>name</em> of the enum instance; however, 
in the nullSafeSet() method you use

preparedStatement.setString(index, value.toString());

which calls toString() on the enum object (if I understand what's going
on correctly).  Unless I'm missing something, the class as written will
fail for any enum where the result returned by name() doesn't match up
with the result returned by toString(), because what it reads from the
database won't match what it writes.
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]