Annotation Interface EnableJdbcRepositories
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:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?>[]Type-safe alternative tobasePackages()for specifying the packages to scan for annotated components.String[]Base packages to scan for annotated components.booleanConfigures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the repositories infrastructure.Deprecated.booleanConfigures whether to enable default transactions for Spring Data JDBC repositories.Specifies which types are not eligible for component scanning.Specifies which types are eligible for component scanning.Configure the name of theJdbcAggregateOperationsbean to be used to create repositories discovered through this annotation.Deprecated.since 4.0 usejdbcAggregateOperationsRef()instead to ensure consistent configuration repositories.Configures the location of where to find the Spring Data named queries properties file.Class<? extends BeanNameGenerator> Configure a specificBeanNameGeneratorto be used when creating the repository beans.Returns the key of theQueryLookupStrategyto be used for lookup queries for query methods.Class<?> Configure the repository base class to be used to create repository proxies for this particular configuration.Class<?> Returns theFactoryBeanclass to be used for each repository instance.Returns the postfix to be used when looking up custom repository implementations.Configures the name of thePlatformTransactionManagerbean to be used to create repositories discovered through this annotation.String[]Alias for thebasePackages()attribute.
-
Element Details
-
value
String[] valueAlias for thebasePackages()attribute. Allows for more concise annotation declarations e.g.:@EnableJdbcRepositories("org.my.pkg")instead of@EnableJdbcRepositories(basePackages="org.my.pkg").- Default:
{}
-
basePackages
String[] basePackagesBase packages to scan for annotated components.value()is an alias for (and mutually exclusive with) this attribute.Supports
${…}placeholders which are resolved against theEnvironmentas 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<?>[] basePackageClassesType-safe alternative tobasePackages()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[] includeFiltersSpecifies which types are eligible for component scanning. Further narrows the set of candidate components from everything inbasePackages()to everything in the base packages that matches the given filter or filters.- Default:
{}
-
excludeFilters
ComponentScan.Filter[] excludeFiltersSpecifies which types are not eligible for component scanning.- Default:
{}
-
repositoryImplementationPostfix
String repositoryImplementationPostfixReturns the postfix to be used when looking up custom repository implementations. Defaults to Impl. So for a repository namedPersonRepositorythe corresponding implementation class will be looked up scanning forPersonRepositoryImpl.- Default:
"Impl"
-
namedQueriesLocation
String namedQueriesLocationConfigures the location of where to find the Spring Data named queries properties file. Will default toMETA-INF/jdbc-named-queries.properties.- Default:
""
-
queryLookupStrategy
QueryLookupStrategy.Key queryLookupStrategyReturns the key of theQueryLookupStrategyto be used for lookup queries for query methods. Defaults toQueryLookupStrategy.Key.CREATE_IF_NOT_FOUND.- Since:
- 2.1
- Default:
CREATE_IF_NOT_FOUND
-
repositoryFactoryBeanClass
Class<?> repositoryFactoryBeanClassReturns theFactoryBeanclass to be used for each repository instance. Defaults toJdbcRepositoryFactoryBean.- Default:
org.springframework.data.jdbc.repository.support.JdbcRepositoryFactoryBean.class
-
repositoryBaseClass
Class<?> repositoryBaseClassConfigure 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> nameGeneratorConfigure a specificBeanNameGeneratorto be used when creating the repository beans.- Returns:
- the
BeanNameGeneratorto be used or the baseBeanNameGeneratorinterface to indicate context default. - Since:
- 3.4
- Default:
org.springframework.beans.factory.support.BeanNameGenerator.class
-
considerNestedRepositories
boolean considerNestedRepositoriesConfigures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the repositories infrastructure.- Default:
false
-
jdbcAggregateOperationsRef
String jdbcAggregateOperationsRefConfigure the name of theJdbcAggregateOperationsbean to be used to create repositories discovered through this annotation.- Since:
- 4.0
- Default:
""
-
jdbcOperationsRef
Deprecated.since 4.0 usejdbcAggregateOperationsRef()instead to ensure consistent configuration repositories.Configures the name of theNamedParameterJdbcOperationsbean to be used to create repositories discovered through this annotation. Defaults tonamedParameterJdbcTemplate.- Default:
""
-
dataAccessStrategyRef
Deprecated.since 4.0 usejdbcAggregateOperationsRef()instead to ensure consistent configuration repositories.Configures the name of theDataAccessStrategybean to be used to create repositories discovered through this annotation. Defaults todefaultDataAccessStrategy.- Default:
""
-
transactionManagerRef
String transactionManagerRefConfigures the name of thePlatformTransactionManagerbean to be used to create repositories discovered through this annotation. Defaults totransactionManager.- Since:
- 2.1
- Default:
"transactionManager"
-
enableDefaultTransactions
boolean enableDefaultTransactionsConfigures 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
-
jdbcAggregateOperationsRef()instead to ensure consistent configuration repositories.