public class SynchroTableDaoImpl extends Object implements SynchroTableDao
Modifier and Type | Field and Description |
---|---|
protected int |
batchSize |
protected int |
columnCount |
protected Connection |
connection |
protected SynchroDatabaseMetadata |
dbMeta |
protected boolean |
debug |
protected int |
idColumnIndex |
protected int |
insertCount |
protected PreparedStatement |
insertQueryParameterStatement |
protected PreparedStatement |
insertStatement |
protected boolean |
insertStrategyGenerateIdFirst |
protected SynchroPendingOperationBuffer |
pendingOperationBuffer |
protected SynchroInterceptor |
readInterceptor |
protected List<PreparedStatement> |
selectStatements |
protected SynchroTableMetadata |
table |
static String |
TABLE_TEMP_QUERY_PARAMETER |
protected String |
tableName |
protected int |
updateCount |
protected PreparedStatement |
updateStatement |
protected SynchroInterceptor |
writeInterceptor |
Constructor and Description |
---|
SynchroTableDaoImpl(Connection connection,
SynchroTableMetadata table,
boolean enableWriteStatements) |
Modifier and Type | Method and Description |
---|---|
void |
clearCounts() |
void |
close() |
protected void |
closePreviousSelectStatements(PreparedStatement newStatement) |
protected void |
closeSelectStatements() |
long |
count()
Count the number of rows in the table
|
long |
countDataToUpdate(Date fromDate)
Count the number of rows updated since the given date
|
protected String |
createTempQueryParameterQuery(SynchroTableMetadata table) |
void |
deleteAll()
Delete all rows of a table
|
void |
executeInsert(Object[] incomingData)
Insert into a table the current row of the given incoming data
Same as
#executeInsert(List,ResultSet) , but using a array instead of a ResultSet. |
void |
executeInsert(ResultSet incomingData)
Insert into a table the current row of the given
ResultSet |
Integer |
executeInsertAndReturnId(ResultSet incomingData) |
void |
executeUpdate(List<Object> pk,
Object[] row)
Update one table's row, using the current row of the given array of values
Same as
SynchroTableDao.executeUpdate(List,ResultSet) , but using a array instead of a ResultSet. |
void |
executeUpdate(List<Object> pk,
ResultSet incomingData)
Update one table's row, using the current row of the given
ResultSet |
Object[] |
findByPk(List<Object> pk)
Obtains a row, using values of each PK
|
void |
flush()
Flush all pending updates (i.e. pending batch statement)
|
Integer |
generateNewId() |
Connection |
getConnection() |
ResultSet |
getDataByFk(String fkColumnName,
Set<Integer> fkValues)
Getting all row depending of parent FK values
|
protected ResultSet |
getDataByFkUsingTempParameterTable(String fkColumnName,
Set<Integer> fkValues) |
protected ResultSet |
getDataByFkWithInOperator(String fkColumnName,
Set<Integer> fkValues) |
ResultSet |
getDataToUpdate(Date fromDate)
Obtains all data updated since the given date (or all data if the given date is null
|
Set<String> |
getExistingPrimaryKeys()
Obtains all primary keys of a table.
|
Map<Integer,Integer> |
getExistingRemoteIdsMap()
Obtains existing remoteIds
|
Integer |
getIdFromRemoteId(String tableName,
Integer remoteId)
Retrieve a id by a remote id.
|
int |
getInsertCount()
Obtains the number of inserted rows
|
Timestamp |
getLastUpdateDate()
Gets the last updateDate for the given
table using
the given datasource. |
SynchroPendingOperationBuffer |
getPendingOperationBuffer() |
List<Object> |
getPk(ResultSet incomingData)
Obtains a PK from the current ResultSet's row
|
List<Object> |
getPk(ResultSet incomingData,
SynchroWriteBuffer transformResult) |
SynchroTableMetadata |
getTable() |
int |
getUpdateCount()
Obtains the number of updated rows
|
protected void |
insertValuesIntoTempQueryParameter(Set<Integer> parameterValues,
String queryParameterName,
int queryPersonId) |
boolean |
isTempQueryParameterEnable() |
protected void |
setData(PreparedStatement statement,
Object[] values,
List<Object> debugParams) |
protected void |
setData(PreparedStatement statement,
ResultSet incomingData,
List<Object> debugParams) |
void |
setPendingOperationBuffer(SynchroPendingOperationBuffer pendingChangesBuffer) |
protected void |
transformAndSetData(PreparedStatement statement,
Object[] incomingData,
SynchroWriteBuffer transformBuffer,
SynchroInterceptor interceptor,
List<Object> debugParams) |
protected void |
transformAndSetData(PreparedStatement statement,
ResultSet incomingData,
SynchroWriteBuffer transformBuffer,
SynchroInterceptor interceptor,
List<Object> debugParams) |
protected Object[] |
transformData(Object[] incomingData,
SynchroInterceptor interceptor,
SynchroWriteBuffer buffer) |
protected Object[] |
transformData(ResultSet incomingData,
SynchroInterceptor interceptor,
SynchroWriteBuffer buffer) |
public static final String TABLE_TEMP_QUERY_PARAMETER
protected final Connection connection
protected final SynchroDatabaseMetadata dbMeta
protected final SynchroTableMetadata table
protected final PreparedStatement insertStatement
protected final PreparedStatement insertQueryParameterStatement
protected final PreparedStatement updateStatement
protected final List<PreparedStatement> selectStatements
protected final boolean insertStrategyGenerateIdFirst
protected final int columnCount
protected final int batchSize
protected boolean debug
protected int insertCount
protected int updateCount
protected final int idColumnIndex
protected final SynchroInterceptor readInterceptor
protected final SynchroInterceptor writeInterceptor
protected SynchroPendingOperationBuffer pendingOperationBuffer
public SynchroTableDaoImpl(Connection connection, SynchroTableMetadata table, boolean enableWriteStatements) throws SQLException
SQLException
public Connection getConnection()
getConnection
in interface SynchroTableDao
public SynchroTableMetadata getTable()
getTable
in interface SynchroTableDao
public void setPendingOperationBuffer(SynchroPendingOperationBuffer pendingChangesBuffer)
setPendingOperationBuffer
in interface SynchroTableDao
public SynchroPendingOperationBuffer getPendingOperationBuffer()
getPendingOperationBuffer
in interface SynchroTableDao
public int getInsertCount()
SynchroTableDao
getInsertCount
in interface SynchroTableDao
public int getUpdateCount()
SynchroTableDao
getUpdateCount
in interface SynchroTableDao
public void flush() throws SQLException
SynchroTableDao
flush
in interface SynchroTableDao
SQLException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public Timestamp getLastUpdateDate() throws SQLException
table
using
the given datasource.getLastUpdateDate
in interface SynchroTableDao
null
if table does not use a updateDate columns or if
there
is no data in table.SQLException
public long count() throws SQLException
SynchroTableDao
count
in interface SynchroTableDao
SQLException
public long countDataToUpdate(Date fromDate) throws SQLException
SynchroTableDao
countDataToUpdate
in interface SynchroTableDao
SQLException
public ResultSet getDataToUpdate(Date fromDate) throws SQLException
SynchroTableDao
getDataToUpdate
in interface SynchroTableDao
SQLException
public void deleteAll() throws SQLException
SynchroTableDao
deleteAll
in interface SynchroTableDao
SQLException
public Object[] findByPk(List<Object> pk) throws SQLException
SynchroTableDao
findByPk
in interface SynchroTableDao
pk
- values of PK columnSQLException
public Set<String> getExistingPrimaryKeys() throws SQLException
SynchroTableDao
SynchroTableMetadata.toPkStr(java.util.List<java.lang.Object>)
getExistingPrimaryKeys
in interface SynchroTableDao
SQLException
public Integer generateNewId() throws SQLException
SQLException
public void executeInsert(ResultSet incomingData) throws SQLException
SynchroTableDao
ResultSet
executeInsert
in interface SynchroTableDao
incomingData
- a ResultSet
with a row ready to be read (ResultSet.next()
should have been call
before)SQLException
public void executeInsert(Object[] incomingData) throws SQLException
SynchroTableDao
#executeInsert(List,ResultSet)
, but using a array instead of a ResultSet.executeInsert
in interface SynchroTableDao
SQLException
public Integer executeInsertAndReturnId(ResultSet incomingData) throws SQLException
executeInsertAndReturnId
in interface SynchroTableDao
SQLException
public void executeUpdate(List<Object> pk, ResultSet incomingData) throws SQLException
SynchroTableDao
ResultSet
executeUpdate
in interface SynchroTableDao
pk
- the PK of the row to updateincomingData
- a ResultSet
with a row ready to be read (ResultSet.next()
should have been call
before)SQLException
public void executeUpdate(List<Object> pk, Object[] row) throws SQLException
SynchroTableDao
SynchroTableDao.executeUpdate(List,ResultSet)
, but using a array instead of a ResultSet.executeUpdate
in interface SynchroTableDao
pk
- the PK of the row to updaterow
- a array of objectSQLException
public ResultSet getDataByFk(String fkColumnName, Set<Integer> fkValues) throws SQLException
SynchroTableDao
getDataByFk
in interface SynchroTableDao
fkColumnName
- the FK column namefkValues
- values of the FK columnsSQLException
public Integer getIdFromRemoteId(String tableName, Integer remoteId) throws SQLException
SynchroTableDao
getIdFromRemoteId
in interface SynchroTableDao
SQLException
public Map<Integer,Integer> getExistingRemoteIdsMap() throws SQLException
SynchroTableDao
getExistingRemoteIdsMap
in interface SynchroTableDao
SQLException
public List<Object> getPk(ResultSet incomingData, SynchroWriteBuffer transformResult) throws SQLException
SQLException
public boolean isTempQueryParameterEnable()
public void clearCounts()
protected void insertValuesIntoTempQueryParameter(Set<Integer> parameterValues, String queryParameterName, int queryPersonId) throws SQLException
SQLException
protected String createTempQueryParameterQuery(SynchroTableMetadata table)
protected void closeSelectStatements()
protected void closePreviousSelectStatements(PreparedStatement newStatement)
protected void setData(PreparedStatement statement, Object[] values, List<Object> debugParams) throws SQLException
SQLException
protected void setData(PreparedStatement statement, ResultSet incomingData, List<Object> debugParams) throws SQLException
SQLException
protected void transformAndSetData(PreparedStatement statement, ResultSet incomingData, SynchroWriteBuffer transformBuffer, SynchroInterceptor interceptor, List<Object> debugParams) throws SQLException
SQLException
protected void transformAndSetData(PreparedStatement statement, Object[] incomingData, SynchroWriteBuffer transformBuffer, SynchroInterceptor interceptor, List<Object> debugParams) throws SQLException
SQLException
protected Object[] transformData(ResultSet incomingData, SynchroInterceptor interceptor, SynchroWriteBuffer buffer) throws SQLException
SQLException
protected Object[] transformData(Object[] incomingData, SynchroInterceptor interceptor, SynchroWriteBuffer buffer) throws SQLException
SQLException
protected ResultSet getDataByFkWithInOperator(String fkColumnName, Set<Integer> fkValues) throws SQLException
SQLException
protected ResultSet getDataByFkUsingTempParameterTable(String fkColumnName, Set<Integer> fkValues) throws SQLException
SQLException
public List<Object> getPk(ResultSet incomingData) throws SQLException
SynchroTableDao
getPk
in interface SynchroTableDao
SQLException
Copyright © 2012–2014 IFREMER. All rights reserved.