HHH-7930 Hibernate will crash with (custom) enum types when running with a logback.xml in debug mode
This commit is contained in:
parent
11e3800f49
commit
6c4df3477f
|
@ -37,11 +37,13 @@ import org.jboss.logging.Logger;
|
|||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.usertype.DynamicParameterizedType;
|
||||
import org.hibernate.usertype.EnhancedUserType;
|
||||
import org.hibernate.usertype.LoggableUserType;
|
||||
|
||||
/**
|
||||
* Value type mapper for enumerations.
|
||||
|
@ -66,7 +68,7 @@ import org.hibernate.usertype.EnhancedUserType;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class EnumType implements EnhancedUserType, DynamicParameterizedType, Serializable {
|
||||
public class EnumType implements EnhancedUserType, DynamicParameterizedType,LoggableUserType, Serializable {
|
||||
private static final Logger LOG = Logger.getLogger( EnumType.class.getName() );
|
||||
|
||||
public static final String ENUM = "enumClass";
|
||||
|
@ -313,6 +315,14 @@ public class EnumType implements EnhancedUserType, DynamicParameterizedType, Ser
|
|||
return enumValueMapper.fromXMLString( xmlValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toLoggableString(Object value, SessionFactoryImplementor factory) {
|
||||
if ( enumValueMapper != null ) {
|
||||
return enumValueMapper.toXMLString( (Enum) value );
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
private static interface EnumValueMapper extends Serializable {
|
||||
public int getSqlType();
|
||||
public Enum getValue(ResultSet rs, String[] names) throws SQLException;
|
||||
|
|
Loading…
Reference in New Issue