
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
|
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 |
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 |
setValues(DbPreparedStatement preparedStatement,
DbValue[] values)
Set several values to a DbPreparedStatement
|
void |
update()
Update object to table
|
static void |
validateLength(byte[]... values)
Validate Byte array max length
|
static void |
validateLength(int type,
String... values)
Validate String max length
|
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
WaarpDatabaseExceptionpublic void select()
throws WaarpDatabaseException
WaarpDatabaseExceptionpublic void insert()
throws WaarpDatabaseException
WaarpDatabaseExceptionpublic void update()
throws WaarpDatabaseException
WaarpDatabaseExceptionpublic final DbValue[] getAllFields()
public void delete()
throws WaarpDatabaseException
WaarpDatabaseExceptionpublic abstract void changeUpdatedInfo(AbstractDbData.UpdatedInfo info)
info - protected abstract void setToArray()
throws WaarpDatabaseSqlException
WaarpDatabaseSqlExceptionprotected abstract void setFromArray()
throws WaarpDatabaseSqlException
WaarpDatabaseSqlExceptionpublic static void validateLength(byte[]... values)
throws WaarpDatabaseSqlException
values - the values to check against Types.VARBINARYWaarpDatabaseSqlException - if length is not acceptablepublic static void validateLength(int type,
String... values)
throws WaarpDatabaseSqlException
type - between Types.VARCHAR, NVARCHAR, LONGVARCHARvalues - the values to check against same typeWaarpDatabaseSqlException - if length is not acceptablepublic static void setTrueValue(PreparedStatement ps, DbValue value, int rank) throws WaarpDatabaseSqlException
ps - value - rank - >= 1WaarpDatabaseSqlExceptionprotected final void setValues(DbPreparedStatement preparedStatement, DbValue[] values) throws WaarpDatabaseNoConnectionException, WaarpDatabaseSqlException
preparedStatement - values - WaarpDatabaseNoConnectionExceptionWaarpDatabaseSqlExceptionpublic static void getTrueValue(ResultSet rs, DbValue value) throws WaarpDatabaseSqlException
rs - value - WaarpDatabaseSqlExceptionprotected void getValues(DbPreparedStatement preparedStatement, DbValue[] values) throws WaarpDatabaseNoConnectionException, WaarpDatabaseSqlException
preparedStatement - values - WaarpDatabaseNoConnectionExceptionWaarpDatabaseSqlExceptionpublic 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 JsonWaarpDatabaseSqlExceptionCopyright © 2009–2022 Waarp. All rights reserved.