On Wed, Mar 14, 2012 at 2:28 PM, michael keith <michael.keith_at_oracle.com> wrote:
> My first question would be to ask why you can't use Bean Validation for some
> of this. Emmanuel would probably be interested in finding out more about
> your use case and what kinds of things validation might need to add to
> accommodate it :-)
It has absolutely nothing to do with Bean Validation. Believe me, I am
on the EG for that one ;-)
> Not sure if I understand your scenario, but I took away from it that you
> will either need to have access to the mapped class in which the converted
> attribute resides, or be able to override the converter for a given type to
> be different for the subtypes. Not sure if that is close, but maybe some
> code snippets would help...
Basically, for when you read data from the PreparedStatement instance,
you need to convert it to the proper Enum instance. For that, you need
to use Enum.valueOf(Class<T> enumType, String name) . Therefore,
access to the class will be needed somehow.
Currently, the only way is either to build one instance per Enum
class, which is somewhat ridiculous giving everything else is the
same. It would make much more sense to have access to the actual
target class as a parameter so this wouldn't be needed.
I hope my use case is clear now.
Michael Nascimento Santos
http://threeten.sf.net/