there's a first issue that makes the enum type to be wrong. It should be a VARCHAR according to ORM, so GlassFish is probably overriding it or doing something very messy.
Nah, the issue is actually all related and it's a class loader problem as I suspected. We basically were using the current thread's class loader inside TypeResolver#heuristicType to load o.h.type.EnumType before we called TypeFactory#byClass. This presents an issue because inside #byClass, we don't see EnumType as a UserType and so the fallback of Serializable happens and so the heuristic lookup returns the SerializableType type instead leading to the wrong data column type and the serialization issue. If we use the ClassLoaderService instead to load the class, the problem disappears. Its really odd we need to make this change here but its definitely GlassFish specific. |