org.singlet.dao
Class SingletDAOImpl

java.lang.Object
  extended by org.singlet.dao.SingletDAOImpl
All Implemented Interfaces:
SingletDAO

public class SingletDAOImpl
extends java.lang.Object
implements SingletDAO


Constructor Summary
SingletDAOImpl()
           
SingletDAOImpl(java.lang.String filePath)
           
 
Method Summary
 int delete(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap)
          This method is used to delete data in database.
 void executeDDL(java.sql.Connection conn, java.lang.String sqlId)
          This method is used to execute DDL queries.
 int insert(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> dataMap)
          This method is used to insert or update data in database.
 java.lang.String[] insert(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> dataMap, boolean generateKeys)
           
 int[] insertBatch(java.sql.Connection conn, java.lang.String sqlId, java.util.List<java.util.LinkedHashMap<java.lang.String,java.lang.String>> batchMapList, java.lang.Integer batchCount)
          This method is used to insert or update data in database in batches.
 int insertUpdate(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> dataMap)
          This method is used to insert or update data in database.
 java.lang.Object read(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap)
          This method is used to read data from database.
 java.lang.Object read(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap, java.lang.String outputType)
          This method is used to read data from database.
 java.lang.Object read(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap, java.lang.String sortName, java.lang.String sortOrder, java.lang.String outputType)
          This method is used to read data from database.
 java.lang.Object read(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap, java.lang.String sortName, java.lang.String sortOrder, java.lang.String outputType, java.lang.Integer startLimit, java.lang.Integer endLimit)
          This method is used to read data from database.
 int update(java.sql.Connection conn, java.lang.String sqlId, java.util.LinkedHashMap<java.lang.String,java.lang.String> setMap, java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap)
          This method is used to update data in database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingletDAOImpl

public SingletDAOImpl()
               throws DataException
Throws:
DataException

SingletDAOImpl

public SingletDAOImpl(java.lang.String filePath)
               throws DataException
Throws:
DataException
Method Detail

insert

public int insert(java.sql.Connection conn,
                  java.lang.String sqlId,
                  java.util.LinkedHashMap<java.lang.String,java.lang.String> dataMap)
           throws DataException,
                  java.lang.Exception
Description copied from interface: SingletDAO
This method is used to insert or update data in database.

Specified by:
insert in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in configuration file
dataMap - - data that need to be updated
Returns:
int - number of records inserted
Throws:
DataException - - exception due to SQL execution
java.lang.Exception

insertUpdate

public int insertUpdate(java.sql.Connection conn,
                        java.lang.String sqlId,
                        java.util.LinkedHashMap<java.lang.String,java.lang.String> dataMap)
                 throws DataException
Description copied from interface: SingletDAO
This method is used to insert or update data in database.

Specified by:
insertUpdate in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in configuration file
Returns:
int - number of records inserted
Throws:
DataException - - exception due to SQL execution

insert

public java.lang.String[] insert(java.sql.Connection conn,
                                 java.lang.String sqlId,
                                 java.util.LinkedHashMap<java.lang.String,java.lang.String> dataMap,
                                 boolean generateKeys)
                          throws DataException
Specified by:
insert in interface SingletDAO
Throws:
DataException

insertBatch

public int[] insertBatch(java.sql.Connection conn,
                         java.lang.String sqlId,
                         java.util.List<java.util.LinkedHashMap<java.lang.String,java.lang.String>> batchMapList,
                         java.lang.Integer batchCount)
                  throws DataException
Description copied from interface: SingletDAO
This method is used to insert or update data in database in batches.

Specified by:
insertBatch in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in configuration file
batchMapList - - list of mapped data to insert
batchCount - - no of records to be executed in batch at one time. Say if there are 100 records need to be inserted and batch count is 50 update will be executed 2 times.
Returns:
int[] - number of records inserted
Throws:
DataException - - exception due to SQL execution

read

public java.lang.Object read(java.sql.Connection conn,
                             java.lang.String sqlId,
                             java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap)
                      throws DataException
Description copied from interface: SingletDAO
This method is used to read data from database.

Specified by:
read in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in configuration file
whereMap - - data which maps to where clause of the query
Returns:
2D String Array
Throws:
DataException - - exception due to SQL execution

read

public java.lang.Object read(java.sql.Connection conn,
                             java.lang.String sqlId,
                             java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap,
                             java.lang.String outputType)
                      throws DataException
Description copied from interface: SingletDAO
This method is used to read data from database.

Specified by:
read in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the sql defined in configuration file
whereMap - - data which maps to where clause of the query
outputType - - type of expected output (JSON/2D Array)
Returns:
JSON String or 2D String Array(default)
Throws:
DataException - - exception due to sql execution

read

public java.lang.Object read(java.sql.Connection conn,
                             java.lang.String sqlId,
                             java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap,
                             java.lang.String sortName,
                             java.lang.String sortOrder,
                             java.lang.String outputType)
                      throws DataException
Description copied from interface: SingletDAO
This method is used to read data from database.

Specified by:
read in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in configuration file
whereMap - - data which maps to where clause of the query
sortName - - column name in query which need to be sorted.
sortOrder - - order by in query(asc/desc)
outputType - - type of expected output (JSON/2D Array)
Returns:
JSON String or 2D String Array(default)
Throws:
DataException - - exception due to SQL execution

read

public java.lang.Object read(java.sql.Connection conn,
                             java.lang.String sqlId,
                             java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap,
                             java.lang.String sortName,
                             java.lang.String sortOrder,
                             java.lang.String outputType,
                             java.lang.Integer startLimit,
                             java.lang.Integer endLimit)
                      throws DataException
Description copied from interface: SingletDAO
This method is used to read data from database. It supports only MySQL with this release 1.0.1

Specified by:
read in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in configuration file
whereMap - - data which maps to where clause of the query
sortName - - column name in query which need to be sorted.
sortOrder - - order by in query(asc/desc)
outputType - - type of expected output (JSON/2D Array)
startLimit - - starting row of the result to be retrieved(help in pagination)
endLimit - - ending row of the result to be retrieved(help in pagination)
Returns:
JSON String or 2D String Array(default)
Throws:
DataException - - exception due to SQL execution

update

public int update(java.sql.Connection conn,
                  java.lang.String sqlId,
                  java.util.LinkedHashMap<java.lang.String,java.lang.String> setMap,
                  java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap)
           throws DataException
Description copied from interface: SingletDAO
This method is used to update data in database.

Specified by:
update in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in configuration file
setMap - - data which maps set clause of the query
whereMap - - data which maps to where clause of the query
Returns:
int - number of records updated
Throws:
DataException - - exception due to SQL execution

delete

public int delete(java.sql.Connection conn,
                  java.lang.String sqlId,
                  java.util.LinkedHashMap<java.lang.String,java.lang.String> whereMap)
           throws DataException
Description copied from interface: SingletDAO
This method is used to delete data in database.

Specified by:
delete in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in configuration file
whereMap - - data which maps to where clause of the query
Returns:
int - number of records deleted
Throws:
DataException - - exception due to SQL execution

executeDDL

public void executeDDL(java.sql.Connection conn,
                       java.lang.String sqlId)
                throws DataException
Description copied from interface: SingletDAO
This method is used to execute DDL queries.

Specified by:
executeDDL in interface SingletDAO
Parameters:
conn - - database connection
sqlId - - id for the SQL defined in config file
Throws:
DataException