Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Generic Dao is a Java package which allows a developer to skip writing
DAOs for their persistence objects when they are using Spring and/or Hibernate.
The package was originally created by Aaron Zeckoski for the Evaluation System
project but was repackaged to make it distributable by request. It is used in the
RSF framework (http://www2.caret.cam.ac.uk/rsfwiki/). Note about the BeanUtils
provided dependency: BeanUtils is not required if you are not using it in your
project. Note about the Hibernate provided dependency: Hibernate is not required
if you are not using it in your project.
/**
* $Id$
* $URL$
* JdbcGeneralGenericDao.java - genericdao - Apr 26, 2008 4:33:33 PM - azeckoski
**************************************************************************
* Copyright (c) 2008 Aaron Zeckoski
* Licensed under the Apache License, Version 2
*
* A copy of the Apache License, Version 2 has been included in this
* distribution and is available at: http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Aaron Zeckoski ([email protected]) ([email protected]) ([email protected])
*/
package org.sakaiproject.genericdao.springjdbc;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.sql.DataSource;
import org.azeckoski.reflectutils.ArrayUtils;
import org.azeckoski.reflectutils.ReflectUtils;
import org.sakaiproject.genericdao.api.GeneralGenericDao;
import org.sakaiproject.genericdao.api.mappers.DataMapper;
import org.sakaiproject.genericdao.api.mappers.NamesRecord;
import org.sakaiproject.genericdao.api.mappers.StatementMapper;
import org.sakaiproject.genericdao.api.translators.DatabaseTranslator;
import org.sakaiproject.genericdao.springjdbc.translators.BasicTranslator;
import org.sakaiproject.genericdao.util.JDBCUtils;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
/**
* A spring JDBC based implementation of {@link GeneralGenericDao}
* which can be extended to add more specialized DAO methods.
* This should meet most DAO needs.
*
* See the overview for installation/usage tips.
*
* @author Aaron Zeckoski ([email protected])
*/
public class JdbcGeneralGenericDao extends JdbcBasicGenericDao implements GeneralGenericDao {
/**
* Default constructor - does nothing and leaves the object in an incomplete state,
* you need to at least set the following:
* {@link #setDataSource(DataSource)}
* {@link #setAutoDDL(boolean)}
* {@link #setAutoCommitDDL(boolean)}
* {@link #setDatabaseType(String)}
* {@link #setDataMappers(List)}
*
* This does not actually start the DAO, run {@link #startup()} to start it
* Note that this will be started automatically by Spring if this is created as a Spring bean,
* no actions are necessary and setting an init method is not needed
*/
public JdbcGeneralGenericDao() {
super();
}
/**
* Complete constructor, sets all required values for running the DAO,
* does not actually start the DAO, run {@link #startup()} to start it
* Note that this will be started automatically by Spring if this is created as a Spring bean,
* no actions are necessary and setting an init method is not needed
*
* @param dataSource the DataSource to use with this DAO
* @param threadBoundDataSource if true then the DataSource will be bound to threads and
* only unbound and closed when {@link #closeConnection()} is called,
* otherwise a new DataSource is obtained each time,
* this has no effect if the DataSource is a Spring DataSource
* @param databaseType the databaseType that this DAO is connecting to (use constants in {@link DatabaseTranslator})
* @param autoDDL if true then DDL is executed on DAO startup (can be run manually if desired)
* @param autoCommitDDL if true then commit is executed after each DDL file is executed, if false then you need a TX manager to do this for you
* @param dataMappers the data mappers which map this DAO to the tables
*/
public JdbcGeneralGenericDao(DataSource dataSource, boolean threadBoundDataSource,
String databaseType, boolean autoDDL, boolean autoCommitDDL, DataMapper[] dataMappers) {
super(dataSource, threadBoundDataSource, databaseType, autoDDL, autoCommitDDL, dataMappers);
}
protected class MyPSS implements BatchPreparedStatementSetter {
private NamesRecord namesRecord;
private List dataKeys = new ArrayList();
private List