public abstract class AbstractDbData extends Object
If the connection is in autocommit, this is the right abstract to
extend.
If the connection is not in autocommit, one could use this implementation to
explicitly commit when needed.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractDbData.UpdatedInfo
UpdatedInfo status
|
Modifier and Type | Field and Description |
---|---|
protected DbValue[] |
allFields |
protected DbSession |
dbSession
The DbSession to use
|
protected boolean |
isSaved |
static String |
JSON_MODEL |
protected DbValue[] |
otherFields |
protected DbValue[] |
primaryKey
To be implemented
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractDbData()
Abstract constructor to set the DbSession to use
|
protected |
AbstractDbData(DbSession dbSession)
Abstract constructor to set the DbSession to use
|
Modifier and Type | Method and Description |
---|---|
String |
asJson() |
abstract void |
changeUpdatedInfo(AbstractDbData.UpdatedInfo info)
Change UpdatedInfo status
|
void |
delete()
Delete object from table
|
boolean |
exist()
Test the existence of the current object
|
boolean |
get(DbPreparedStatement preparedStatement)
Get Values from PreparedStatement
|
DbValue[] |
getAllFields() |
protected abstract String |
getInsertAllValues() |
com.fasterxml.jackson.databind.node.ObjectNode |
getJson()
Create the equivalent object in Json (no database access)
|
protected abstract String |
getSelectAllFields() |
protected abstract String |
getTable() |
static void |
getTrueValue(ResultSet rs,
DbValue value)
Get one value into DbValue from ResultSet
|
protected abstract String |
getUpdateAllFields() |
protected void |
getValue(DbPreparedStatement preparedStatement,
DbValue value)
Get one value into DbValue from DbPreparedStatement
|
protected void |
getValues(DbPreparedStatement preparedStatement,
DbValue[] values)
Get several values into DbValue from DbPreparedStatement
|
protected abstract String |
getWherePrimaryKey() |
protected abstract void |
initObject()
To setup primaryKey, otherFields, allFields.
|
void |
insert()
Insert object into table
|
void |
select()
Select object from table
|
protected abstract void |
setFromArray()
Internal function to retrieve data from Array to pull data from database
|
void |
setFromJson(com.fasterxml.jackson.databind.node.ObjectNode node,
boolean ignorePrimaryKey)
Set the values from the Json node to the current object (no database
access)
|
protected abstract void |
setPrimaryKey()
Set the primary Key as current value
|
protected abstract void |
setToArray()
Internal function to set to Array used to push data to database
|
static void |
setTrueValue(PreparedStatement ps,
DbValue value,
int rank)
Set Value into PreparedStatement
|
protected void |
setValue(DbPreparedStatement preparedStatement,
DbValue value)
Set one value to a DbPreparedStatement
|
protected void |
setValues(DbPreparedStatement preparedStatement,
DbValue[] values)
Set several values to a DbPreparedStatement
|
void |
update()
Update object to table
|
public static final String JSON_MODEL
protected DbValue[] primaryKey
protected DbValue[] otherFields
protected DbValue[] allFields
protected boolean isSaved
protected final DbSession dbSession
protected AbstractDbData(DbSession dbSession)
dbSession
- Deprecated for Waarp R66protected AbstractDbData()
protected abstract void initObject()
protected abstract String getWherePrimaryKey()
protected abstract void setPrimaryKey()
protected abstract String getSelectAllFields()
protected abstract String getTable()
protected abstract String getInsertAllValues()
protected abstract String getUpdateAllFields()
public boolean exist() throws WaarpDatabaseException
WaarpDatabaseException
public void select() throws WaarpDatabaseException
WaarpDatabaseException
public void insert() throws WaarpDatabaseException
WaarpDatabaseException
public void update() throws WaarpDatabaseException
WaarpDatabaseException
public DbValue[] getAllFields()
public void delete() throws WaarpDatabaseException
WaarpDatabaseException
public abstract void changeUpdatedInfo(AbstractDbData.UpdatedInfo info)
info
- protected abstract void setToArray()
protected abstract void setFromArray() throws WaarpDatabaseSqlException
WaarpDatabaseSqlException
public static void setTrueValue(PreparedStatement ps, DbValue value, int rank) throws WaarpDatabaseSqlException
ps
- value
- rank
- >= 1WaarpDatabaseSqlException
protected void setValue(DbPreparedStatement preparedStatement, DbValue value) throws WaarpDatabaseNoConnectionException, WaarpDatabaseSqlException
preparedStatement
- value
- WaarpDatabaseNoConnectionException
WaarpDatabaseSqlException
protected void setValues(DbPreparedStatement preparedStatement, DbValue[] values) throws WaarpDatabaseNoConnectionException, WaarpDatabaseSqlException
preparedStatement
- values
- WaarpDatabaseNoConnectionException
WaarpDatabaseSqlException
public static void getTrueValue(ResultSet rs, DbValue value) throws WaarpDatabaseSqlException
rs
- value
- WaarpDatabaseSqlException
protected void getValue(DbPreparedStatement preparedStatement, DbValue value) throws WaarpDatabaseNoConnectionException, WaarpDatabaseSqlException
preparedStatement
- value
- WaarpDatabaseNoConnectionException
WaarpDatabaseSqlException
protected void getValues(DbPreparedStatement preparedStatement, DbValue[] values) throws WaarpDatabaseNoConnectionException, WaarpDatabaseSqlException
preparedStatement
- values
- WaarpDatabaseNoConnectionException
WaarpDatabaseSqlException
public boolean get(DbPreparedStatement preparedStatement)
preparedStatement
- public String asJson()
public com.fasterxml.jackson.databind.node.ObjectNode getJson()
public void setFromJson(com.fasterxml.jackson.databind.node.ObjectNode node, boolean ignorePrimaryKey) throws WaarpDatabaseSqlException
node
- ignorePrimaryKey
- True will ignore primaryKey from JsonWaarpDatabaseSqlException
Copyright © 2009–2020 Waarp. All rights reserved.