public class

JdbcBeanDefinitionReader

extends Object
java.lang.Object
   ↳ org.springframework.jdbc.core.support.JdbcBeanDefinitionReader

Class Overview

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.

Summary

Public Constructors
JdbcBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
Create a new JdbcBeanDefinitionReader for the given bean factory, using a default PropertiesBeanDefinitionReader underneath.
JdbcBeanDefinitionReader(PropertiesBeanDefinitionReader beanDefinitionReader)
Create a new JdbcBeanDefinitionReader that delegates to the given PropertiesBeanDefinitionReader underneath.
Public Methods
void loadBeanDefinitions(String sql)
Load bean definitions from the database via the given SQL string.
void setDataSource(DataSource dataSource)
Set the DataSource to use to obtain database connections.
void setJdbcTemplate(JdbcTemplate jdbcTemplate)
Set the JdbcTemplate to be used by this bean factory.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

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.

public JdbcBeanDefinitionReader (PropertiesBeanDefinitionReader beanDefinitionReader)

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

DataSource or JdbcTemplate still need to be set.

Public Methods

public void loadBeanDefinitions (String sql)

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

Parameters
sql 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.

public void setDataSource (DataSource dataSource)

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

public void setJdbcTemplate (JdbcTemplate jdbcTemplate)

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