tarantool / cartridge-springdata

Spring Data Tarantool
Other
18 stars 7 forks source link

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

Open ArtDu opened 2 years ago

ArtDu commented 2 years ago

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);
    }