cartridge-springdata icon indicating copy to clipboard operation
cartridge-springdata copied to clipboard

Add fix to use Field annotation in entity methods(getters)

Open ArtDu opened this issue 3 years ago • 0 comments

Now it doesn't work like that, see the test here: https://github.com/tarantool/cartridge-springdata/pull/87

It is also worth considering that findMergedAnnotation is a performance-heavy method, so should cache getting annotations or come up with something so as not to use annotation search for each parameter field in each call request

@Override
    public String getFieldName() {
        Field annotationField = AnnotatedElementUtils.findMergedAnnotation(getField(), Field.class);

        if (annotationField != null && StringUtils.hasText(annotationField.value())) {
            return annotationField.value();
        }

        return fieldNamingStrategy.getFieldName(this);
    }

ArtDu avatar Feb 18 '22 14:02 ArtDu