openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobias Trelle <>
Subject Re: Mapping CHAR column to String
Date Fri, 12 Nov 2010 11:48:30 GMT

Kevin Sutter wrote:
> The @Strategy annotation is defined to work at the type (Entity) level.
> But, that would mean that all attributes in that entity would utilize your
> defined Strategy.  I doubt that would work for your scenario.  Other than
> that, the only currently defined means is to specify the Strategy as you
> need it for each attribute.

I found a smart solution for this problem. It is possible to register field
strategies per Java type. This is done via an OpenJPA property in


Now all String attributes (in all entities) are processed by the
CharValueHandler (without annotating any single attribute!). This is
basically what we need.

But I like to narrow it down only the CHAR columns (with VARCHAR columns I
don't need and want to pad the string with spaces before INSERT or UPDATE).
Is there a way to extract the DB column type within a ValueHandler? The
interface methods are provided with a ValueMapping. Column#getJavaType
provides the type information on the Java side, not the DB column type. Any


View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message