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 persistence.xml: <property name="openjpa.jdbc.MappingDefaults" value="FieldStrategies='java.lang.String=com.xxx.beispielanwendung.firmenverwaltung.entity.CharValueHandler'" /> 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 ideas? TIA, Tobias -- View this message in context: http://openjpa.208410.n2.nabble.com/Mapping-CHAR-column-to-String-tp5727930p5732057.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
