From: jonsmallberries (A. F. <fo...@an...> - 2005-11-30 21:40:17
|
Hello, I've run into an incredibly annoying issue. I have an entity class ParameterSet, that is associated with a Collection of entity Parameter classes. The Parameter class is made up of simple value type attributes and two type safe enumerations. One of the type safe enumerations is called ValueType (code below). The method nullSafeGet(ResultSet resultSet, String[] values, Object owner) throws a NullPointerException under 3.1-RC1 because the ResultSet returns null. This attribute was marked with a multiplicity of 0...1, and is allowed to be null in the DB, so it seems like this should not be throwing a NullPointerException, when that Enumeration attribute is allowed to be null. // license-header java merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: HibernateEnumeration.vsl in andromda-hibernate-cartridge. // package com.sys.ianm.commplanner.enumerations; import org.hibernate.HibernateException; import java.sql.Types; import java.sql.ResultSet; import java.sql.PreparedStatement; import java.sql.SQLException; /** * */ public final class ValueTypeEnum extends ValueType implements java.io.Serializable, java.lang.Comparable, org.hibernate.usertype.UserType { private static final int[] SQL_TYPES = {Types.VARCHAR}; /** * Default constructor. Hibernate needs the default constructor * to retrieve an instance of the enum from a JDBC resultset. * The instance will be converted to the correct enum instance * in {@link #nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object)}. */ public ValueTypeEnum() { super(); } /** * @see org.hibernate.usertype.UserType#sqlTypes() */ public int[] sqlTypes() { return SQL_TYPES; } /** * @see org.hibernate.usertype.UserType#deepCopy(java.lang.Object) */ public Object deepCopy(Object value) throws HibernateException { // Enums are immutable - nothing to be done to deeply clone it return value; } /** * @see org.hibernate.usertype.UserType#isMutable() */ public boolean isMutable() { // Enums are immutable return false; } /** * @see org.hibernate.usertype.UserType#equals(java.lang.Object, java.lang.Object) */ public boolean equals(Object x, Object y) throws HibernateException { return (x == y) || (x != null && y != null && y.equals(x)); } /** * @see org.hibernate.usertype.UserType#returnedClass() */ public Class returnedClass() { return ValueType.class; } /** * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object) */ public Object nullSafeGet(ResultSet resultSet, String[] values, Object owner) throws HibernateException, SQLException { final int value = ((java.lang.Integer)resultSet.getObject(values[0])).intValue(); return resultSet.wasNull() ? null : fromInt(value); } /** * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int) */ public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException { if (value == null) { statement.setNull(index, Types.VARCHAR); } else { statement.setObject(index, java.lang.Integer.valueOf(java.lang.String.valueOf(value))); } } /** * @see org.hibernate.usertype.UserType#replace(Object original, Object target, Object owner) */ public Object replace(Object original, Object target, Object owner) { return original; } /** * @see org.hibernate.usertype.UserType#assemble(java.io.Serializable cached, Object owner) */ public Object assemble(java.io.Serializable cached, Object owner) { return cached; } /** * @see org.hibernate.usertype.UserType#assemble(Object value) */ public java.io.Serializable disassemble(Object value) { return (java.io.Serializable)value; } /** * @see org.hibernate.usertype.UserType#assemble(Object value) */ public int hashCode(Object x) { return x.hashCode(); } } [/code] -- Remember, no matter where you go...there you are. --Buckaroo Banzai _________________________________________________________ Reply to the post : http://galaxy.andromda.org/forum/viewtopic.php?p=7460#7460 Posting to http://forum.andromda.org/ is preferred over posting to the mailing list! |