Annotation Interface EnableJdbcRepositories


@Target(TYPE) @Retention(RUNTIME) @Documented @Inherited @Import(org.springframework.data.jdbc.repository.config.JdbcRepositoriesRegistrar.class) public @interface EnableJdbcRepositories
Annotation to enable JDBC repositories. If no base package is configured through either * value(), basePackages() or basePackageClasses() it will trigger scanning of the package of annotated class.

Enabling JDBC repositories prefers a JdbcAggregateOperations bean and falls back to creating a JdbcAggregateTemplate instance from configured or discovered Dialect, DataAccessStrategy, and NamedParameterJdbcOperations beans.

Configuring jdbcAggregateOperationsRef() allows a consistent configuration using all involved components including reference lookups. dataAccessStrategyRef() and jdbcOperationsRef() are deprecated since 4.0 and will be removed in a future version as not all required components can be configured properly for a consistent repository configuration.

Author:
Jens Schauder, Greg Turnquist, Mark Paluch, Fei Dong, Antoine Sauray, Diego Krupitza, Christoph Strobl
See Also:
  • Element Details

    • value

      String[] value
      Alias for the basePackages() attribute. Allows for more concise annotation declarations e.g.: @EnableJdbcRepositories("org.my.pkg") instead of @EnableJdbcRepositories(basePackages="org.my.pkg").
      Default:
      {}
    • basePackages

      String[] basePackages
      Base packages to scan for annotated components.

      value() is an alias for (and mutually exclusive with) this attribute.

      Supports ${…} placeholders which are resolved against the Environment as well as Ant-style package patterns — for example, "org.example.**".

      Multiple packages or patterns may be specified, either separately or within a single String — for example, {"org.example.config", "org.example.service.**"} or "org.example.config, org.example.service.**".

      Use basePackageClasses() for a type-safe alternative to String-based package names.

      See Also:
      Default:
      {}
    • basePackageClasses

      Class<?>[] basePackageClasses
      Type-safe alternative to basePackages() for specifying the packages to scan for annotated components. The package of each class specified will be scanned. Consider creating a special no-op marker class or interface in each package that serves no purpose other than being referenced by this attribute.
      Default:
      {}
    • includeFilters

      ComponentScan.Filter[] includeFilters
      Specifies which types are eligible for component scanning. Further narrows the set of candidate components from everything in basePackages() to everything in the base packages that matches the given filter or filters.
      Default:
      {}
    • excludeFilters

      ComponentScan.Filter[] excludeFilters
      Specifies which types are not eligible for component scanning.
      Default:
      {}
    • repositoryImplementationPostfix

      String repositoryImplementationPostfix
      Returns the postfix to be used when looking up custom repository implementations. Defaults to Impl. So for a repository named PersonRepository the corresponding implementation class will be looked up scanning for PersonRepositoryImpl.
      Default:
      "Impl"
    • namedQueriesLocation

      String namedQueriesLocation
      Configures the location of where to find the Spring Data named queries properties file. Will default to META-INF/jdbc-named-queries.properties.
      Default:
      ""
    • queryLookupStrategy

      QueryLookupStrategy.Key queryLookupStrategy
      Returns the key of the QueryLookupStrategy to be used for lookup queries for query methods. Defaults to QueryLookupStrategy.Key.CREATE_IF_NOT_FOUND.
      Since:
      2.1
      Default:
      CREATE_IF_NOT_FOUND
    • repositoryFactoryBeanClass

      Class<?> repositoryFactoryBeanClass
      Returns the FactoryBean class to be used for each repository instance. Defaults to JdbcRepositoryFactoryBean.
      Default:
      org.springframework.data.jdbc.repository.support.JdbcRepositoryFactoryBean.class
    • repositoryBaseClass

      Class<?> repositoryBaseClass
      Configure the repository base class to be used to create repository proxies for this particular configuration.
      Since:
      2.1
      Default:
      org.springframework.data.repository.config.DefaultRepositoryBaseClass.class
    • nameGenerator

      Class<? extends BeanNameGenerator> nameGenerator
      Configure a specific BeanNameGenerator to be used when creating the repository beans.
      Returns:
      the BeanNameGenerator to be used or the base BeanNameGenerator interface to indicate context default.
      Since:
      3.4
      Default:
      org.springframework.beans.factory.support.BeanNameGenerator.class
    • considerNestedRepositories

      boolean considerNestedRepositories
      Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the repositories infrastructure.
      Default:
      false
    • jdbcAggregateOperationsRef

      String jdbcAggregateOperationsRef
      Configure the name of the JdbcAggregateOperations bean to be used to create repositories discovered through this annotation.
      Since:
      4.0
      Default:
      ""
    • jdbcOperationsRef

      @Deprecated(since="4.0") String jdbcOperationsRef
      Deprecated.
      since 4.0 use jdbcAggregateOperationsRef() instead to ensure consistent configuration repositories.
      Configures the name of the NamedParameterJdbcOperations bean to be used to create repositories discovered through this annotation. Defaults to namedParameterJdbcTemplate.
      Default:
      ""
    • dataAccessStrategyRef

      @Deprecated(since="4.0") String dataAccessStrategyRef
      Deprecated.
      since 4.0 use jdbcAggregateOperationsRef() instead to ensure consistent configuration repositories.
      Configures the name of the DataAccessStrategy bean to be used to create repositories discovered through this annotation. Defaults to defaultDataAccessStrategy.
      Default:
      ""
    • transactionManagerRef

      String transactionManagerRef
      Configures the name of the PlatformTransactionManager bean to be used to create repositories discovered through this annotation. Defaults to transactionManager.
      Since:
      2.1
      Default:
      "transactionManager"
    • enableDefaultTransactions

      boolean enableDefaultTransactions
      Configures whether to enable default transactions for Spring Data JDBC repositories. Defaults to true. If disabled, repositories must be used behind a facade that's configuring transactions (e.g. using Spring's annotation driven transaction facilities) or repository methods have to be used to demarcate transactions.
      Returns:
      whether to enable default transactions, defaults to true.
      Since:
      4.0
      Default:
      true