Spring Framework JdbcDaoSupport - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework JdbcDaoSupport class.

This code example shows how to use the following methods:
 * @author Thomas Risberg 
 * @author Juergen Hoeller 
 * @since 2.0 
 * @see NamedParameterJdbcTemplate 
 */ 
public class NamedParameterJdbcDaoSupport extends JdbcDaoSupport {
 
	private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
 
 
	/** 
	 * Create a NamedParameterJdbcTemplate based on the configured JdbcTemplate. 
	 */ 
	@Override 
	protected void initTemplateConfig() { 
		this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate());
	} 
 
	/** 
	 * Return a NamedParameterJdbcTemplate wrapping the configured JdbcTemplate. 
6
CodeRank
This code example shows how to use the following methods:getDataSource, initDao
 
	private SimpleJdbcInsert insertGame;
 
	@Override 
	protected void initDao() throws Exception {
		super.initDao(); 
		insertGame = new SimpleJdbcInsert(getDataSource()).withTableName("GAMES").usingColumns("player_id", "year_no",
				"team", "week", "opponent", " completes", "attempts", "passing_yards", "passing_td", "interceptions", 
				"rushes", "rush_yards", "receptions", "receptions_yards", "total_td"); 
	} 
 
	@Override 
	public void write(List<? extends Game> games) {
 
		for (Game game : games) {
 
			SqlParameterSource values = new MapSqlParameterSource().addValue("player_id", game.getId()).addValue(
					"year_no", game.getYear()).addValue("team", game.getTeam()).addValue("week", game.getWeek())
					.addValue("opponent", game.getOpponent()).addValue("completes", game.getCompletes()).addValue(
							"attempts", game.getAttempts()).addValue("passing_yards", game.getPassingYards()).addValue(
6
CodeRank
This code example shows how to use the following methods:
 * @deprecated since Spring 3.1 in favor of {@link org.springframework.jdbc.core.support.JdbcDaoSupport} and 
 * {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport}. The JdbcTemplate and 
 * NamedParameterJdbcTemplate now provide all the functionality of the SimpleJdbcTemplate. 
 */ 
@Deprecated 
public class SimpleJdbcDaoSupport extends JdbcDaoSupport {
 
	private SimpleJdbcTemplate simpleJdbcTemplate;
 
 
	/** 
	 * Create a SimpleJdbcTemplate based on the configured JdbcTemplate. 
	 */ 
	@Override 
	protected void initTemplateConfig() { 
		this.simpleJdbcTemplate = new SimpleJdbcTemplate(getJdbcTemplate());
	} 
 
	/** 
	 * Return a SimpleJdbcTemplate wrapping the configured JdbcTemplate. 
6
CodeRank
This code example shows how to use the following methods:getJdbcTemplate, setDataSource
  @Test 
  public void testHiveInstall() { 
    HiveConfigurationSchemaInstaller installer = new HiveConfigurationSchemaInstaller(getConnectString(TEST_DB)); 
    installer.run(); 
    JdbcDaoSupport dao = new SimpleJdbcDaoSupport(); 
    dao.setDataSource(getDataSource(TEST_DB)); 
    int rowCount = dao.getJdbcTemplate().queryForInt("select count(1) from semaphore_metadata"); 
    Assert.assertEquals(1, rowCount); 
  } 
 
  @Override 
  public Collection<String> getDatabaseNames() { 
    return Arrays.asList(new String[]{TEST_DB}); 
  } 
} 
6
CodeRank
This code example shows how to use the following methods:
import org.springframework.util.SerializationUtils; 
 
/** 
 * Database {@link ItemWriter} implementing the process indicator pattern. 
 */ 
public class StagingItemWriter<T> extends JdbcDaoSupport implements StepExecutionListener, ItemWriter<T> { 
 
	protected static final String NEW = "N"; 
 
	protected static final String DONE = "Y"; 
 
	private DataFieldMaxValueIncrementer incrementer; 
 
	private StepExecution stepExecution; 
 
	/** 
	 * Check mandatory properties. 
	 * 
	 * @see org.springframework.dao.support.DaoSupport#initDao() 
	 */ 
5
CodeRank
This code example shows how to use the following methods:
import org.springframework.jdbc.object.SqlFunction; 
 
/** 
 * @author Thierry Templier 
 */ 
public class DocumentIdDaoImpl extends JdbcDaoSupport implements DocumentIdDao { 
 
	public long getNextDocumentId() { 
		SqlFunction sqlFunction = new SqlFunction(getDataSource(), 
									"select next_document_id from document_id"); 
		sqlFunction.compile(); 
		return sqlFunction.run(); 
	} 
 
	public void incrementDocumentId() { 
		SqlFunction sqlFunction = new SqlFunction(getDataSource(), 
									"select next_document_id from document_id"); 
		sqlFunction.compile(); 
		int nextDocumentId = sqlFunction.run(); 
		getJdbcTemplate().update("update document_id set next_document_id=?", 
5
CodeRank
This code example shows how to use the following methods:
import org.springmodules.samples.lucene.bean.indexing.DocumentCategory; 
 
/** 
 * @author Thierry Templier 
 */ 
public class CategoryDaoImpl extends JdbcDaoSupport implements CategoryDao { 
 
	private class CategoriesMappingQuery extends MappingSqlQuery { 
 
		public CategoriesMappingQuery(DataSource ds) { 
			super(ds, "SELECT CATEGORY_ID,CATEGORY_NAME FROM CATEGORY"); 
			compile(); 
		} 
 
		public Object mapRow(ResultSet rs, int rowNumber) throws SQLException { 
			DocumentCategory category = new DocumentCategory(rs.getInt("CATEGORY_ID"), 
													rs.getString("CATEGORY_NAME")); 
			return category; 
		}  
	} 
5
CodeRank
This code example shows how to use the following methods:
import com.jeecms.cms.dao.assist.CmsDataBackDao; 
import com.jeecms.cms.entity.back.CmsField; 
import com.jeecms.cms.Constants; 
 
@Repository 
public class CmsDataBackDaoImpl extends JdbcDaoSupport implements 
		CmsDataBackDao { 
 
	public String createTableDDL(String tablename) { 
		String sql = " show create table " + tablename; 
		String ddl = getJdbcTemplate().queryForObject(sql, 
				new RowMapper<String>() { 
					public String mapRow(ResultSet set, int arg1) 
							throws SQLException { 
						return set.getString(2); 
					} 
				}); 
		return ddl; 
	} 
 
5
CodeRank
This code example shows how to use the following methods:
 
/** 
 * The TableDao implementation.  Persistence mechanism is a database. 
 */ 
 
public class JdbcTableDao extends JdbcDaoSupport implements TableDao { 
 
     private SimpleJdbcInsert insertActor; 
 
    /** 
     * Looks up and retrieves a table from the database using the table id. 
     *  
     * @param tableId  The id of the table we are trying to locate (will be unique for each table).  
     * @return  The table represented as a Table object.    
     * @throws RecoverableDataAccessException  If unable to lookup table with the given table id.  
     */ 
    public Table lookupTable(int tableId) { 
        String sql = "SELECT * FROM tables WHERE tableId = ?"; 
        List<Table> tables = getJdbcTemplate().query(sql, new TableMapper(), tableId);  
        if (tables.isEmpty()) { 
4
CodeRank
This code example shows how to use the following methods:setDataSource
 */ 
@Repository 
public class UserDaoImpl extends JdbcDaoSupport implements DaoInterface<User>{ 
 
    @Autowired 
    public UserDaoImpl(DataSource dataSource) { 
        setDataSource(dataSource); 
    } 
     
    @Override 
    public List<User> listarTodos() { 
        return getJdbcTemplate().query( 
                "select * from sunat_user", 
                new BeanPropertyRowMapper<User>(User.class)); 
    } 
 
    @Override 
    public Integer insertar(User object) { 
        getJdbcTemplate().update( 
                "insert into sunat_user(full_name, username, salt, password," 
5
CodeRank
See Code Examples for Spring Framework JdbcDaoSupport Methods: