Annotation Interface ConvertWith


@Retention(RUNTIME) @Target({ANNOTATION_TYPE,FIELD}) @Inherited @Documented @API(status=STABLE, since="6.0") public @interface ConvertWith
This annotation can be used to define either custom conversions for single attributes by specifying a custom Neo4jPersistentPropertyConverter and if needed, a custom factory to create that converter or the annotation can be used to build custom meta-annotated annotations like @org.springframework.data.neo4j.core.support.DateLong.

Custom conversions are applied to both attributes of entities and parameters of repository methods that map to those attributes (which does apply to all derived queries and queries by example but not to string based queries).

Converters that have a default constructor don't need a dedicated factory. A dedicated factory will be provided with either this annotation and its values or with the meta annotated annotation, including all configuration available.

In case converterRef() is set to a non null and non-empty value, the mapping context will try to lookup a bean under the given name of type Neo4jPersistentPropertyConverter in the application context. If no such bean is found an exception will be thrown. This attribute has precedence over converter().

Since:
6.0
Author:
Michael J. Simons
  • Element Details

    • converter

      Class<? extends Neo4jPersistentPropertyConverter<?>> converter
      Returns:
      The converter to instantiated for converting attributes to properties and vice versa.
      Default:
      org.springframework.data.neo4j.core.convert.ConvertWith.UnsetConverter.class
    • converterFactory

      Class<? extends Neo4jPersistentPropertyConverterFactory> converterFactory
      Returns:
      An alternative to converter(), for all the scenarios in which constructing a converter is more effort than a constructor call.
      Default:
      org.springframework.data.neo4j.core.convert.DefaultNeo4jPersistentPropertyConverterFactory.class
    • converterRef

      String converterRef
      Returns:
      An optional reference to a bean to be used as converter, must implement Neo4jPersistentPropertyConverter.
      Default:
      ""