From ad5dd18aacf1b7fd3b0b9d520a9a5d9d91b95827 Mon Sep 17 00:00:00 2001 From: Kristian Marinkovic Date: Wed, 15 May 2013 21:23:32 +0200 Subject: [PATCH] HHH-4699 trim value from database before Enum.valueOf() this change fixes the problem with fixed size columns with enum values that are right padded. --- .../src/main/java/org/hibernate/type/EnumType.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java index b73a608aa3..2892b9dc6b 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java @@ -455,7 +455,10 @@ public class EnumType implements EnhancedUserType, DynamicParameterizedType,Logg private Enum fromName(String name) { try { - return Enum.valueOf( enumClass, name ); + if(name == null) { + return null; + } + return Enum.valueOf( enumClass, name.trim() ); } catch ( IllegalArgumentException iae ) { throw new IllegalArgumentException(