Top Description Fields Constructors Methods
org.springframework.jdbc.core.support

public Class JdbcBeanDefinitionReader

extends Object
Class Inheritance
Annotations
@Deprecated
Imports
java.util.Properties, javax.sql.DataSource, org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.jdbc.core.JdbcTemplate, org.springframework.lang.Nullable, org.springframework.util.Assert

Deprecated

as of 5.3, in favor of Spring's common bean definition formats and/or custom reader implementations

Bean definition reader that reads values from a database table, based on a given SQL statement.

Expects columns for bean name, property name and value as String. Formats for each are identical to the properties format recognized by PropertiesBeanDefinitionReader.

Note

This is mainly intended as an example for a custom JDBC-based bean definition reader. It does not aim to offer comprehensive functionality.

Authors
Rod Johnson, Juergen Hoeller
See Also
loadBeanDefinitions, org.springframework.beans.factory.support.PropertiesBeanDefinitionReader

Field Summary

Modifier and TypeField and Description
private JdbcTemplate
private final PropertiesBeanDefinitionReader
propReader

Deprecated as a consequence of PropertiesBeanDefinitionReader being deprecated.

Constructor Summary

AccessConstructor and Description
public
JdbcBeanDefinitionReader(BeanDefinitionRegistry beanFactory)

Create a new JdbcBeanDefinitionReader for the given bean factory, using a default PropertiesBeanDefinitionReader underneath.

public
JdbcBeanDefinitionReader(PropertiesBeanDefinitionReader reader)

Deprecated as a consequence of PropertiesBeanDefinitionReader being deprecated.
Create a new JdbcBeanDefinitionReader that delegates to the given PropertiesBeanDefinitionReader underneath.

Method Summary

Modifier and TypeMethod and Description
public void
loadBeanDefinitions(String
the SQL query to use for loading bean definitions. The first three columns must be bean name, property name and value. Any join and any other columns are permitted: e.g. SELECT BEAN_NAME, PROPERTY, VALUE FROM CONFIG WHERE CONFIG.APP_ID = 1 It's also possible to perform a join. Column names are not significant -- only the ordering of these first three columns.
sql
)

Load bean definitions from the database via the given SQL string.

public void
setDataSource(DataSource dataSource)

Set the DataSource to use to obtain database connections.

public void
setJdbcTemplate(JdbcTemplate jdbcTemplate)

Set the JdbcTemplate to be used by this bean factory.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

jdbcTemplateback to summary
private JdbcTemplate jdbcTemplate
Annotations
@Nullable
propReaderback to summary
private final PropertiesBeanDefinitionReader propReader

Deprecated

as a consequence of PropertiesBeanDefinitionReader being deprecated. See corresponding docs for further information.

Constructor Detail

JdbcBeanDefinitionReaderback to summary
public JdbcBeanDefinitionReader(BeanDefinitionRegistry beanFactory)

Create a new JdbcBeanDefinitionReader for the given bean factory, using a default PropertiesBeanDefinitionReader underneath.

DataSource or JdbcTemplate still need to be set.

See Also
setDataSource, setJdbcTemplate
JdbcBeanDefinitionReaderback to summary
public JdbcBeanDefinitionReader(PropertiesBeanDefinitionReader reader)

Deprecated

as a consequence of PropertiesBeanDefinitionReader being deprecated. See corresponding docs for further information.

Create a new JdbcBeanDefinitionReader that delegates to the given PropertiesBeanDefinitionReader underneath.

DataSource or JdbcTemplate still need to be set.

See Also
setDataSource, setJdbcTemplate

Method Detail

loadBeanDefinitionsback to summary
public void loadBeanDefinitions(String sql)

Load bean definitions from the database via the given SQL string.

Parameters
sql:String

the SQL query to use for loading bean definitions. The first three columns must be bean name, property name and value. Any join and any other columns are permitted: e.g. SELECT BEAN_NAME, PROPERTY, VALUE FROM CONFIG WHERE CONFIG.APP_ID = 1 It's also possible to perform a join. Column names are not significant -- only the ordering of these first three columns.

setDataSourceback to summary
public void setDataSource(DataSource dataSource)

Set the DataSource to use to obtain database connections. Will implicitly create a new JdbcTemplate with the given DataSource.

setJdbcTemplateback to summary
public void setJdbcTemplate(JdbcTemplate jdbcTemplate)

Set the JdbcTemplate to be used by this bean factory. Contains settings for DataSource, SQLExceptionTranslator, etc.