JPA Attribute validation skipped with converter


The attachment is a Junit test to reproduce the case. I hope you can add it to DN test-suite.

here is the field with the converter, where length is 4096 (over 255 to be sure)
@Convert(converter = AddressToStringConverter.class)
@Column(columnDefinition = "VARCHAR(4096)", length = 4096)
@Size(max = 4096)
private Address addressString;

The converter transforming an Address to a string of 1024 bytes.
public String convertToDatabaseColumn(Address attribute) {
if (attribute == null) {
return null;
byte[] tmp = new byte[1024];
Arrays.fill(tmp, (byte) 's');
return new String(tmp);

The error message requesting a string length of 255.

java.lang.AssertionError: Failed test : Attempt to store value "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" in column "ADDRESSSTRING" that has maximum length of 255. Please correct your data!



Post the relevant bits of relevant classes in the POST, no time to download.
A length of a column is only used in schema generation.

@Size is part of javax.validation (not JPA), which is something else entirely, and I would expect that to apply to the Java field when it is a String, and yours is presumably not if using a converter.



When I use an attribute converter on an attribute, DN does not load the length validation attribute, keeping its default 255 value. (debug shows the length attribute is 255, probably not loaded)
Test case attached (last code version). In business code, I want to store the result from a rest-service.

I tried many options with @Column length, @Size, ... same result. I also tried to do not validate constraints (datanucleus.validation.mode=none). Same results.
Am I wrong somewhere or any workaround I can play with ?