public class DBPersist
extends com.knowgate.storage.AbstractRecord
Core class for persisting Java objects as registers in a RDMS.
Althought not an abstract class, DBPersist is mainly designed to be inherited by a child class implementing specific behavior for reading a writting a Java object from and to a relational database.
DBPersist mantains an internal collection of values each one mapped to a database field.
This mapping is done automatically by DBPersist reading the target table metadata definition and preparing the proper internal value set.This object keeps the internal value set in memory as long as it is not garbage collected, but it does not mantaing any session information nor transaction management with the database. It is the programmer's responsability to pass an open database connection on each method call and to commit or rollback transaction involving the usage of a DBPersist object.
Constructor and Description |
---|
DBPersist(java.lang.String sTable,
java.lang.String sAuditClass)
Create instance for reading and writing register from a table
|
DBPersist(java.lang.String sTable,
java.lang.String sAuditClass,
boolean bAllValuesUpperCase)
Create instance for reading and writing register from a table
|
Modifier and Type | Method and Description |
---|---|
boolean |
allcaps()
Get allcaps state
|
void |
allcaps(boolean bAllValuesUpperCase)
Automatically convert put string values to uppercase
|
void |
clear()
Clears internal values.
|
void |
clone(DBPersist oSource)
Copy another DBPersist into this instance
Table and audit class values are replaced with to ones from source object
|
java.util.LinkedList<com.knowgate.storage.Column> |
columns()
Get list of columns from underlying table of this DBPersist
Table and audit class values are replaced with to ones from source object
|
boolean |
containsKey(java.lang.Object oKey)
Returns true if this DBPersist contains a field for the given name
|
boolean |
containsValue(java.lang.Object oKey)
Returns true if any of this DBPersist fields has the specified value.
|
boolean |
delete(JDCConnection oConn)
Delete a register from database
The deleted register will be the one matching this DBPersist primary key,
as set at constructor or load() method.
|
java.util.Set |
entrySet() |
boolean |
exists(JDCConnection oConn)
Find out whether or not a particular register exists at database
|
java.lang.Object |
get(java.lang.Object oKey)
Get value for a field name
|
java.lang.Object |
get(java.lang.String sKey)
Get value for a field name
|
java.lang.String |
getAuditClassName()
Get audit class name
|
java.util.Date |
getCreationDate(JDCConnection oConn)
Get dt_created column of register corresponding to this DBPersist instace
|
java.util.Date |
getDate(java.lang.String sKey)
Get value for a DATETIME field
|
java.util.Date |
getDate(java.lang.String sKey,
java.util.Date dtDefault)
Get value for a DATETIME field
|
java.lang.String |
getDateFormated(java.lang.String sKey,
java.lang.String sFormat)
Get value for a DATE, DATETIME or TIMESTAMP field formated a String
|
java.lang.String |
getDateShort(java.lang.String sKey)
Get DATE formated as ccyy-MM-dd
|
java.lang.String |
getDateTime(java.lang.String sKey)
Get value for a DATE, DATETIME or TIMESTAMP field formated a yyyy-MM-dd hh:mm:ss
|
java.lang.String |
getDateTime24(java.lang.String sKey)
Get value for a DATE, DATETIME or TIMESTAMP field formated a yyyy-MM-dd HH:mm:ss
|
java.math.BigDecimal |
getDecimal(java.lang.String sKey)
Get value for a DECIMAL or NUMERIC field
|
java.lang.String |
getDecimalFormated(java.lang.String sKey,
java.util.Locale oLoc,
int nFractionDigits)
Get BigDecimal formated as a String using the given locale and fractional digits
|
java.lang.String |
getDecimalFormated(java.lang.String sKey,
java.lang.String sPattern)
Get BigDecimal formated as a String using the given pattern and the symbols for the default locale
|
double |
getDouble(java.lang.String sKey)
Get value for a DOUBLE or NUMBER([1..28],m) field
|
java.lang.String |
getDoubleFormated(java.lang.String sKey,
java.lang.String sPattern)
Get double formated as a String using the given pattern and the symbols for the default locale
|
float |
getFloat(java.lang.String sKey)
Get value for a FLOAT or NUMBER([1..28],m) field
|
java.lang.String |
getFloatFormated(java.lang.String sKey,
java.lang.String sPattern)
Get float formated as a String using the given pattern and the symbols for the default locale
|
int |
getInt(java.lang.String sKey)
Get value for a INTEGER or NUMBER([1..11]) field
|
int[] |
getIntArray(java.lang.String sKey)
Get value for an _int4[] field
|
java.lang.Integer |
getInteger(java.lang.String sKey)
Get value for a INTEGER or NUMBER([1..11]) field
|
java.lang.Integer[] |
getIntegerArray(java.lang.String sKey)
Get value for an _int4[] field
|
int |
getIntervalPart(java.lang.String sKey,
java.lang.String sPart)
Get a part of an interval value
This function only works for PostgreSQL
|
java.util.HashMap |
getItemMap() |
java.util.Set |
getItems()
Deprecated.
Use keySet() instead
|
Money |
getMoney(java.lang.String sKey)
Get value of a VARCHAR field that holds a money+currency amount
Money values are stored with its currency sign embedded inside,
like "26.32 USD" or "$48.3" or "35.44 €"
|
java.lang.String |
getPrimaryKey()
Get value of primary key field for this DBPersist record
|
short |
getShort(java.lang.String sKey)
Get value for a SMALLINT field
|
java.sql.Date |
getSQLDate(java.lang.String sKey)
Get value for a DATE field
|
java.sql.Time |
getSQLTime(java.lang.String sKey)
Get value for a TIME field
|
java.lang.String |
getString(java.lang.String sKey)
Get value for a CHAR, VARCHAR or LONGVARCHAR field
|
java.lang.String |
getStringHtml(java.lang.String sKey,
java.lang.String sDefault) |
java.lang.String |
getStringNull(java.lang.String sKey,
java.lang.String sDefault)
Get value for a CHAR, VARCHAR or LONGVARCHAR field replacing null
with a default value.
|
DBTable |
getTable()
Deprecated.
Use
getTable(JDCConnection) instead |
DBTable |
getTable(JDCConnection oConn)
Get DBTable object witch holds this DBPersist registers.
|
java.lang.String |
getTime(java.lang.String sKey)
Get time part of date as a String
|
java.sql.Time |
getTimeOfDay(java.lang.String sKey)
Get value for SQL92 TIME field
|
java.sql.Timestamp |
getTimestamp(java.lang.String sKey)
Get value for a DATETIME or TIMESTAMP field
|
boolean |
isEmpty()
Returns whether or not this DBPersist contains no field values
|
boolean |
isNull(java.lang.String sKey)
Test is a readed field was null.
|
java.util.Iterator |
iterator() |
java.util.Set |
keySet() |
boolean |
load(JDCConnection oConn,
java.lang.Object[] PKVals)
Load the internal value set from a register at a database table
|
boolean |
load(JDCConnection oConn,
java.lang.String sKey)
Load the internal value set from a register at a database table
|
void |
parseXML(java.lang.String sXMLFilePath)
Load an XML String into DBPersist internal collection.
|
java.lang.Object |
put(java.lang.Object sKey,
java.lang.Object oObj)
Set value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.
|
void |
put(java.lang.String sKey,
java.sql.Array aVal)
Put Array value at internal collection
|
void |
put(java.lang.String sKey,
java.math.BigDecimal oDecVal)
Put BigDecimal value at internal collection
|
void |
put(java.lang.String sKey,
byte byVal)
Set value at internal collection
|
void |
put(java.lang.String sKey,
byte[] aBytes)
Set reference to a byte array for a long field
Use this method only for binding LONGVARBINARY or BLOB fields
|
void |
put(java.lang.String sKey,
char[] aChars)
Set reference to a character array for a long field
Use this method only for binding LONGVARCHAR or CLOB fields
|
void |
put(java.lang.String sKey,
java.util.Date dtVal)
Set value at internal collection
|
void |
put(java.lang.String sKey,
double dVal)
Put double value at internal collection
|
void |
put(java.lang.String sKey,
java.lang.Double oDbl)
Set Double value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.
|
void |
put(java.lang.String sKey,
java.io.File oFile)
Set reference to a binary file for a long field
|
void |
put(java.lang.String sKey,
float fVal)
Put float value at internal collection
|
void |
put(java.lang.String sKey,
java.lang.Float oFlt)
Set Float value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.
|
void |
put(java.lang.String sKey,
int iVal)
Set value at internal collection
|
void |
put(java.lang.String sKey,
java.lang.Integer oInt)
Set Integer value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.
|
void |
put(java.lang.String sKey,
Money mVal)
Put Money value at internal collection
|
void |
put(java.lang.String sKey,
java.lang.Object oObj)
Set value at internal collection
|
void |
put(java.lang.String sKey,
short iVal)
Set value at internal collection
|
void |
put(java.lang.String sKey,
java.lang.Short oShr)
Set Short value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.
|
void |
put(java.lang.String sKey,
java.lang.String sVal)
Set value at internal collection
If allcaps is set tu true then sVal is converted to uppercase
|
void |
put(java.lang.String sKey,
java.lang.String sDecVal,
java.text.DecimalFormat oPattern)
Parse BigDecimal value and put it at internal collection
|
void |
put(java.lang.String sKey,
java.lang.String sData,
int iSQLType)
Set value at internal collection
|
void |
put(java.lang.String sKey,
java.lang.String sDate,
java.text.SimpleDateFormat oPattern)
Put Date value using specified format
|
void |
put(java.lang.String sKey,
java.sql.Time tmVal)
Set value at internal collection
|
void |
putAll(java.util.Map oMap)
Put values from a Map into this DBPersist instance
allcaps has no effect on input data when calling this method
|
void |
putAll(java.util.Properties oPropsCollection)
Load values from a Properties object
|
java.lang.Object |
remove(java.lang.Object oKey)
Remove a value from internal collection
|
void |
remove(java.lang.String sKey)
Remove a value from internal collection
|
void |
replace(java.lang.String sKey,
double dVal)
Replace a value from internal collection
|
void |
replace(java.lang.String sKey,
float fVal)
Replace a value from internal collection
|
void |
replace(java.lang.String sKey,
int iVal)
Replace a value from internal collection
|
void |
replace(java.lang.String sKey,
Money mVal)
Replace a value from internal collection
|
void |
replace(java.lang.String sKey,
java.lang.Object oObj)
Replace a value from internal collection
|
void |
replace(java.lang.String sKey,
short iVal)
Replace a value from internal collection
|
void |
replace(java.lang.String sKey,
java.lang.String sData,
int iSQLType)
Replace value at internal collection
|
void |
replace(java.lang.String sKey,
java.lang.String sDate,
java.text.SimpleDateFormat oPattern)
Replace Date value using specified format
|
void |
setAuditTransact(java.lang.String sAuditTransact)
Set transaction id for automatic operation auditing.
|
void |
setAuditUser(java.lang.String sAuditUser)
Set user id for automatic operation auditing.
|
void |
setCreationDate(JDCConnection oConn,
java.util.Date dtCreated)
Set dt_created column of register corresponding to this DBPersist instace
|
void |
setPrimaryKey(java.lang.String sValue)
Set value of primary key field for this DBPersist record
|
int |
size()
Actual number of field values on this DBPersist
|
boolean |
store(JDCConnection oConn)
Store a register at database representing this instance of DBPersist
Insertions and updates : The store method automatically manages
register insertions and updates.
|
void |
toLowerCase(java.lang.String sKey)
Convert value kept with given key to lowercase
|
void |
toUpperCase(java.lang.String sKey)
Convert value kept with given key to uppercase
|
java.lang.String |
toXML()
Get an XML dump for the DBPersist values.
|
java.lang.String |
toXML(java.lang.String sIdent)
Get an XML dump for the DBPersist values.
|
java.lang.String |
toXML(java.lang.String sIdent,
java.lang.String sDelim)
Get an XML dump for the DBPersist values
|
java.util.Collection |
values() |
public DBPersist(java.lang.String sTable, java.lang.String sAuditClass) throws java.lang.IllegalStateException
sTable
- Database table name for storing objects.sAuditClass
- Name of child Java class inheriting from DBPersist.java.lang.IllegalStateException
public DBPersist(java.lang.String sTable, java.lang.String sAuditClass, boolean bAllValuesUpperCase) throws java.lang.IllegalStateException
sTable
- Database table name for storing objects.sAuditClass
- Name of child Java class inheriting from DBPersist.bAllValuesUpperCase
- Convert all put string values to uppercasejava.lang.IllegalStateException
public void allcaps(boolean bAllValuesUpperCase)
bAllValuesUpperCase
- booleanpublic boolean allcaps()
public void setAuditUser(java.lang.String sAuditUser)
public void setAuditTransact(java.lang.String sAuditTransact)
public boolean isEmpty()
isEmpty
in interface java.util.Map
isEmpty
in class java.util.HashMap
public int size()
size
in interface java.util.Map
size
in class java.util.HashMap
public void clear()
Clears internal values.
No register is deleted at the database.
clear
in interface java.util.Map
clear
in class java.util.HashMap
public void clone(DBPersist oSource)
Copy another DBPersist into this instance
Table and audit class values are replaced with to ones from source objectoSource
- Source Objectpublic java.util.LinkedList<com.knowgate.storage.Column> columns()
Get list of columns from underlying table of this DBPersist
Table and audit class values are replaced with to ones from source objectcolumns
in interface com.knowgate.storage.Record
columns
in class com.knowgate.storage.AbstractRecord
oSource
- Source Objectpublic boolean containsValue(java.lang.Object oKey)
containsValue
in interface java.util.Map
containsValue
in class java.util.HashMap
oKey
- Object whose presence in this map is to be testedpublic boolean containsKey(java.lang.Object oKey) throws java.lang.NullPointerException
containsKey
in interface java.util.Map
containsKey
in class java.util.HashMap
oKey
- Field Namejava.lang.NullPointerException
- If oKey is nullpublic java.lang.Object get(java.lang.String sKey)
Get value for a field name
sKey
- String Field Namepublic java.util.Date getCreationDate(JDCConnection oConn) throws java.sql.SQLException
oConn
- JDCConnectionjava.sql.SQLException
- If table for this DBPersist does not have a column named dt_createdpublic void setCreationDate(JDCConnection oConn, java.util.Date dtCreated) throws java.sql.SQLException
oConn
- JDCConnectiondtCreated
- Date If null then current system date is setjava.sql.SQLException
- If table for this DBPersist does not have a column named dt_createdpublic java.lang.Object get(java.lang.Object oKey) throws java.lang.NullPointerException
Get value for a field name
get
in interface java.util.Map
get
in class java.util.HashMap
sKey
- String Field Namejava.lang.NullPointerException
- If oKey is nullpublic java.math.BigDecimal getDecimal(java.lang.String sKey) throws java.lang.ClassCastException, java.lang.NumberFormatException
Get value for a DECIMAL or NUMERIC field
sKey
- Field Namejava.lang.ClassCastException
java.lang.NumberFormatException
public java.lang.String getDecimalFormated(java.lang.String sKey, java.lang.String sPattern) throws java.lang.ClassCastException, java.lang.NumberFormatException, java.lang.NullPointerException, java.lang.IllegalArgumentException
Get BigDecimal formated as a String using the given pattern and the symbols for the default locale
sKey
- Field NamesPattern
- A non-localized pattern string, for example: "#0.00"java.lang.ClassCastException
java.lang.NumberFormatException
java.lang.NullPointerException
- if sPattern is nulljava.lang.IllegalArgumentException
- if sPattern is invalidpublic java.lang.String getDecimalFormated(java.lang.String sKey, java.util.Locale oLoc, int nFractionDigits) throws java.lang.ClassCastException, java.lang.NumberFormatException, java.lang.NullPointerException, java.lang.IllegalArgumentException
Get BigDecimal formated as a String using the given locale and fractional digits
sKey
- Field NameLocale
- nFractionDigits
- Number of digits at the right of the decimal separatorjava.lang.ClassCastException
java.lang.NumberFormatException
java.lang.NullPointerException
- if sPattern is nulljava.lang.IllegalArgumentException
- if sPattern is invalidpublic java.lang.String getDoubleFormated(java.lang.String sKey, java.lang.String sPattern) throws java.lang.ClassCastException, java.lang.NumberFormatException, java.lang.NullPointerException, java.lang.IllegalArgumentException
Get double formated as a String using the given pattern and the symbols for the default locale
sKey
- Field NamesPattern
- A non-localized pattern string, for example: "#0.00"java.lang.ClassCastException
java.lang.NumberFormatException
java.lang.NullPointerException
java.lang.IllegalArgumentException
public java.lang.String getFloatFormated(java.lang.String sKey, java.lang.String sPattern) throws java.lang.ClassCastException, java.lang.NumberFormatException, java.lang.NullPointerException, java.lang.IllegalArgumentException
Get float formated as a String using the given pattern and the symbols for the default locale
sKey
- Field NamesPattern
- A non-localized pattern string, for example: "#0.00"java.lang.ClassCastException
java.lang.NumberFormatException
java.lang.NullPointerException
java.lang.IllegalArgumentException
public Money getMoney(java.lang.String sKey) throws java.lang.NumberFormatException
Get value of a VARCHAR field that holds a money+currency amount
Money values are stored with its currency sign embedded inside, like "26.32 USD" or "$48.3" or "35.44 €"
sKey
- Field Namejava.lang.NumberFormatException
public java.lang.String getString(java.lang.String sKey) throws java.lang.NullPointerException
Get value for a CHAR, VARCHAR or LONGVARCHAR field
getString
in interface com.knowgate.storage.Record
getString
in class com.knowgate.storage.AbstractRecord
sKey
- Field Namejava.lang.NullPointerException
- if field is null or no field with
such name was found at internal value collection.public java.lang.String getStringNull(java.lang.String sKey, java.lang.String sDefault)
Get value for a CHAR, VARCHAR or LONGVARCHAR field replacing null with a default value.
sKey
- Field NamesDefault
- Value to be returned if field is null. sDefault may itself
be null, provinding a null safe version of getString() method.public java.lang.String getStringHtml(java.lang.String sKey, java.lang.String sDefault)
public java.sql.Time getTimeOfDay(java.lang.String sKey)
Get value for SQL92 TIME field
sKey
- Field Namepublic short getShort(java.lang.String sKey) throws java.lang.NullPointerException
Get value for a SMALLINT field
sKey
- Field Namejava.lang.NullPointerException
- if field is null or no field with
such name was found at internal value collection.public double getDouble(java.lang.String sKey) throws java.lang.NullPointerException, java.lang.NumberFormatException
Get value for a DOUBLE or NUMBER([1..28],m) field
sKey
- Field Namejava.lang.NullPointerException
- if field is null or no field with
such name was found at internal value collection.java.lang.NumberFormatException
public float getFloat(java.lang.String sKey) throws java.lang.NullPointerException, java.lang.NumberFormatException
Get value for a FLOAT or NUMBER([1..28],m) field
sKey
- Field Namejava.lang.NullPointerException
- if field is null or no field with
such name was found at internal value collection.java.lang.NumberFormatException
public int getInt(java.lang.String sKey) throws java.lang.NullPointerException, java.lang.NumberFormatException
Get value for a INTEGER or NUMBER([1..11]) field
getInt
in interface com.knowgate.storage.Record
getInt
in class com.knowgate.storage.AbstractRecord
sKey
- Field Namejava.lang.NullPointerException
- if field is null or no field with
such name was found at internal value collection.java.lang.NumberFormatException
public java.lang.Integer getInteger(java.lang.String sKey) throws java.lang.NumberFormatException
Get value for a INTEGER or NUMBER([1..11]) field
getInteger
in interface com.knowgate.storage.Record
getInteger
in class com.knowgate.storage.AbstractRecord
sKey
- Field Namejava.lang.NumberFormatException
public java.util.Date getDate(java.lang.String sKey) throws java.lang.ClassCastException
Get value for a DATETIME field
getDate
in interface com.knowgate.storage.Record
getDate
in class com.knowgate.storage.AbstractRecord
sKey
- Field Namejava.lang.ClassCastException
- if sKey field is not of type DATETIMEpublic java.util.Date getDate(java.lang.String sKey, java.util.Date dtDefault)
Get value for a DATETIME field
getDate
in interface com.knowgate.storage.Record
getDate
in class com.knowgate.storage.AbstractRecord
sKey
- Field NamedtDefault
- Date default valuejava.lang.ClassCastException
- if sKey field is not of type DATETIMEpublic java.lang.String getDateShort(java.lang.String sKey) throws java.lang.ClassCastException
Get DATE formated as ccyy-MM-dd
sKey
- Field Namejava.lang.ClassCastException
- if sKey field is not of type DATEpublic java.lang.String getDateFormated(java.lang.String sKey, java.lang.String sFormat) throws java.lang.ClassCastException
Get value for a DATE, DATETIME or TIMESTAMP field formated a String
sKey
- Field NamesFormat
- Date Format (like "yyyy-MM-dd HH:mm:ss")java.lang.ClassCastException
- if sKey field is not of type DATE, DATETIME or TIMESTAMPSimpleDateFormat
public java.lang.String getDateTime(java.lang.String sKey)
Get value for a DATE, DATETIME or TIMESTAMP field formated a yyyy-MM-dd hh:mm:ss
sKey
- String Field Namejava.lang.ClassCastException
- if sKey field is not of type DATEpublic java.lang.String getDateTime24(java.lang.String sKey)
Get value for a DATE, DATETIME or TIMESTAMP field formated a yyyy-MM-dd HH:mm:ss
sKey
- String Field Namejava.lang.ClassCastException
- if sKey field is not of type DATE, DATETIME or TIMESTAMPpublic java.sql.Date getSQLDate(java.lang.String sKey) throws java.lang.ClassCastException
Get value for a DATE field
sKey
- Field Namejava.lang.ClassCastException
- if sKey field is not of type DATE, DATETIME or TIMESTAMPpublic java.sql.Time getSQLTime(java.lang.String sKey) throws java.lang.ClassCastException
Get value for a TIME field
sKey
- Field Namejava.lang.ClassCastException
public java.lang.String getTime(java.lang.String sKey) throws java.lang.ClassCastException
Get time part of date as a String
sKey
- Field Namejava.lang.ClassCastException
- if sKey field is not of type DATEpublic int getIntervalPart(java.lang.String sKey, java.lang.String sPart) throws java.lang.NullPointerException, java.lang.NumberFormatException, java.lang.IllegalArgumentException
Get a part of an interval value
This function only works for PostgreSQLsKey
- String String Field NamesPart
- String Currently, only "days" is allowed as interval partjava.lang.NullPointerException
- if interval is nulljava.lang.IllegalArgumentException
- is sPart is not "days"java.lang.NumberFormatException
- if interval has no dayspublic java.sql.Timestamp getTimestamp(java.lang.String sKey)
Get value for a DATETIME or TIMESTAMP field
sKey
- Field Namepublic java.lang.Integer[] getIntegerArray(java.lang.String sKey) throws java.sql.SQLException
Get value for an _int4[] field
sKey
- Field Namejava.sql.SQLException
public int[] getIntArray(java.lang.String sKey) throws java.sql.SQLException
Get value for an _int4[] field
sKey
- Field Namejava.sql.SQLException
public java.util.Set getItems()
public java.util.Set keySet()
keySet
in interface java.util.Map
keySet
in class java.util.HashMap
public java.util.HashMap getItemMap()
public java.util.Collection values()
values
in interface java.util.Map
values
in class java.util.HashMap
public java.util.Set entrySet()
entrySet
in interface java.util.Map
entrySet
in class java.util.HashMap
public java.util.Iterator iterator()
public java.lang.String getAuditClassName()
public java.lang.String getPrimaryKey()
getPrimaryKey
in interface com.knowgate.storage.Record
getPrimaryKey
in class com.knowgate.storage.AbstractRecord
public void setPrimaryKey(java.lang.String sValue) throws java.lang.NullPointerException
setPrimaryKey
in interface com.knowgate.storage.Record
setPrimaryKey
in class com.knowgate.storage.AbstractRecord
java.lang.NullPointerException
public DBTable getTable()
getTable(JDCConnection)
insteadDBTable
object where data is stored
or null if the table does not exist at the database.public DBTable getTable(JDCConnection oConn) throws java.sql.SQLException, java.lang.IllegalStateException
oConn
- JDBC Database ConnectionDBTable
object where data is stored
or null if the table does not exist at the database.java.lang.IllegalStateException
- DBPersist uses the internal static table map
from DBBind. The internal DBBind table map is loaded upon first call to
a DBBind constructor. Thus, if a DBPersist object is instantiated before
instantiating any DBBind object, the internal table map will not be
preloaded and an IllegalStateException will be raised.java.sql.SQLException
public boolean isNull(java.lang.String sKey)
isNull
in interface com.knowgate.storage.Record
isNull
in class com.knowgate.storage.AbstractRecord
sKey
- Field Namepublic boolean load(JDCConnection oConn, java.lang.Object[] PKVals) throws java.sql.SQLException
Load the internal value set from a register at a database table
oConn
- Database ConnectionPKVals
- Primary key values in order of appearancejava.sql.SQLException
public boolean load(JDCConnection oConn, java.lang.String sKey) throws java.sql.SQLException
Load the internal value set from a register at a database table
oConn
- JDCConnectionsKey
- String Primary key valuejava.sql.SQLException
public void put(java.lang.String sKey, java.lang.String sVal) throws java.lang.NullPointerException
Set value at internal collection
If allcaps is set tu true then sVal is converted to uppercasesKey
- Field NamesVal
- Field Valuejava.lang.NullPointerException
- If sKey is nullpublic void put(java.lang.String sKey, java.lang.Object oObj) throws java.lang.NullPointerException
Set value at internal collection
sKey
- Field NameoObj
- Field Valuejava.lang.NullPointerException
- If sKey is nullpublic void put(java.lang.String sKey, java.lang.Short oShr) throws java.lang.NullPointerException
Set Short value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.sKey
- Field NameoObj
- Short Valuejava.lang.NullPointerException
- If sKey is nullpublic void put(java.lang.String sKey, java.lang.Integer oInt) throws java.lang.NullPointerException
Set Integer value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.sKey
- Field NameoObj
- Integer Valuejava.lang.NullPointerException
- If sKey is nullpublic void put(java.lang.String sKey, java.lang.Float oFlt) throws java.lang.NullPointerException
Set Float value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.sKey
- Field NameoObj
- Float Valuejava.lang.NullPointerException
- If sKey is nullpublic void put(java.lang.String sKey, java.lang.Double oDbl) throws java.lang.NullPointerException
Set Double value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.sKey
- Field NameoObj
- Double Valuejava.lang.NullPointerException
- If sKey is nullpublic java.lang.Object put(java.lang.Object sKey, java.lang.Object oObj) throws java.lang.NullPointerException
Set value at internal collection
If internal collection previously contained a mapping for this key, the old value is replaced.put
in interface java.util.Map
put
in class java.util.HashMap
sKey
- Field NameoObj
- Field Valuejava.lang.NullPointerException
- If sKey is nullpublic void put(java.lang.String sKey, byte byVal)
Set value at internal collection
sKey
- Field NameiVal
- Field Valuepublic void put(java.lang.String sKey, int iVal)
Set value at internal collection
put
in class com.knowgate.storage.AbstractRecord
sKey
- Field NameiVal
- Field Valuepublic void put(java.lang.String sKey, short iVal)
Set value at internal collection
put
in class com.knowgate.storage.AbstractRecord
sKey
- Field NameiVal
- Field Valuepublic void put(java.lang.String sKey, java.util.Date dtVal)
Set value at internal collection
sKey
- Field NamedtVal
- Field Valuepublic void put(java.lang.String sKey, java.sql.Time tmVal)
Set value at internal collection
sKey
- Field NametmVal
- Field Valuepublic void put(java.lang.String sKey, java.lang.String sDate, java.text.SimpleDateFormat oPattern) throws java.text.ParseException
sKey
- String Field NamesDate
- String Field Value as StringoPattern
- SimpleDateFormat Date format to be usedjava.text.ParseException
public void put(java.lang.String sKey, double dVal)
Put double value at internal collection
put
in class com.knowgate.storage.AbstractRecord
sKey
- Field NamedVal
- Field Valuepublic void put(java.lang.String sKey, java.math.BigDecimal oDecVal)
Put BigDecimal value at internal collection
sKey
- Field NameoDecVal
- Field Valuepublic void put(java.lang.String sKey, java.lang.String sDecVal, java.text.DecimalFormat oPattern) throws java.text.ParseException
sKey
- String Field NamesDecVal
- Field Name as StringoPattern
- DecimalFormatjava.text.ParseException
public void put(java.lang.String sKey, float fVal)
Put float value at internal collection
put
in class com.knowgate.storage.AbstractRecord
sKey
- Field NamefVal
- Field Valuepublic void put(java.lang.String sKey, Money mVal)
Put Money value at internal collection
sKey
- Field NamemVal
- Field Valuepublic void put(java.lang.String sKey, java.io.File oFile) throws java.io.FileNotFoundException
Set reference to a binary file for a long field
sKey
- Field NameoFile
- File Objectjava.io.FileNotFoundException
public void put(java.lang.String sKey, byte[] aBytes)
Set reference to a byte array for a long field
Use this method only for binding LONGVARBINARY or BLOB fields
sKey
- Field NameaBytes
- byte arraypublic void put(java.lang.String sKey, char[] aChars)
Set reference to a character array for a long field
Use this method only for binding LONGVARCHAR or CLOB fields
sKey
- Field NameaChars
- char arraypublic void put(java.lang.String sKey, java.sql.Array aVal)
Put Array value at internal collection
sKey
- Field NameaVal
- Field Valuepublic void put(java.lang.String sKey, java.lang.String sData, int iSQLType) throws java.io.FileNotFoundException, java.lang.IllegalArgumentException, java.lang.NullPointerException
Set value at internal collection
sKey
- Field NamesData
- Field Value as a String. If iSQLType is BLOB or LONGVARBINARY
then sData is interpreted as a full file path uri.iSQLType
- SQL Type for fieldjava.lang.NullPointerException
- If sKey is nulljava.lang.IllegalArgumentException
- If SQL Type is not recognized.
Recognized types are { CHAR, VARCHAR, LONGVARCHAR, CLOB, INTEGER, SMALLINT,
DATE, TIMESTAMP, DOUBLE, FLOAT, REAL, DECIMAL, NUMERIC, BLOB, LONGVARBINARY }java.io.FileNotFoundException
public void putAll(java.util.Properties oPropsCollection) throws java.io.FileNotFoundException
Load values from a Properties object
java.io.FileNotFoundException
public void putAll(java.util.Map oMap)
Put values from a Map into this DBPersist instance
allcaps has no effect on input data when calling this methodputAll
in interface java.util.Map
putAll
in class java.util.HashMap
oMap
- public void remove(java.lang.String sKey)
Remove a value from internal collection
sKey
- Field Namepublic java.lang.Object remove(java.lang.Object oKey)
Remove a value from internal collection
remove
in interface java.util.Map
remove
in class java.util.HashMap
oKey
- Field Namepublic void replace(java.lang.String sKey, java.lang.Object oObj)
Replace a value from internal collection
replace
in interface com.knowgate.storage.Record
replace
in class com.knowgate.storage.AbstractRecord
sKey
- Field NameoObj
- New Valuepublic void replace(java.lang.String sKey, int iVal)
Replace a value from internal collection
sKey
- Field NameiVal
- New int valuepublic void replace(java.lang.String sKey, short iVal)
Replace a value from internal collection
sKey
- Field NameiVal
- New short valuepublic void replace(java.lang.String sKey, float fVal)
Replace a value from internal collection
sKey
- Field NamefVal
- New float valuepublic void replace(java.lang.String sKey, double dVal)
Replace a value from internal collection
sKey
- Field NamedVal
- New double valuepublic void replace(java.lang.String sKey, Money mVal)
Replace a value from internal collection
sKey
- Field NamemVal
- New Money valuepublic void replace(java.lang.String sKey, java.lang.String sDate, java.text.SimpleDateFormat oPattern) throws java.text.ParseException
sKey
- String Field NamesDate
- String Field Value as StringoPattern
- SimpleDateFormat Date format to be usedjava.text.ParseException
public void replace(java.lang.String sKey, java.lang.String sData, int iSQLType) throws java.io.FileNotFoundException, java.lang.IllegalArgumentException, java.lang.NullPointerException
Replace value at internal collection
sKey
- Field NamesData
- Field Value as a String. If iSQLType is BLOB or LONGVARBINARY
then sData is interpreted as a full file path uri.iSQLType
- SQL Type for fieldjava.lang.NullPointerException
- If sKey is nulljava.lang.IllegalArgumentException
- If SQL Type is not recognized.
Recognized types are { CHAR, VARCHAR, LONGVARCHAR, CLOB, INTEGER, SMALLINT,
DATE, TIMESTAMP, DOUBLE, FLOAT, REAL, DECIMAL, NUMERIC, BLOB, LONGVARBINARY }java.io.FileNotFoundException
public void toLowerCase(java.lang.String sKey)
sKey
- Stringpublic void toUpperCase(java.lang.String sKey)
sKey
- Stringpublic boolean store(JDCConnection oConn) throws java.sql.SQLException
Store a register at database representing this instance of DBPersist
Insertions and updates : The store method automatically manages register insertions and updates. If the stored object already exists at database then it is updated, if it does not exists then it is inserted. A primary key violation error is never thrown so ther is no need to call delete() method before re-writing an existing object.
NULL fields : All values not set calling put() methods for DBPersist
will be assumed to be NULL. If a not nullable field is not set then an
SQLException will be raised.
On storing an already existing object all values will we overwrited,
so is a DBPersist is not fully loaded before storing it, values not set
by calling put() methods that already were present at database will be lost.
oConn
- Database Connectionjava.sql.SQLException
public boolean delete(JDCConnection oConn) throws java.sql.SQLException
Delete a register from database
The deleted register will be the one matching this DBPersist primary key, as set at constructor or load() method.
oConn
- Database connectionjava.sql.SQLException
public boolean exists(JDCConnection oConn) throws java.sql.SQLException
Find out whether or not a particular register exists at database
oConn
- database connectionjava.sql.SQLException
public java.lang.String toXML(java.lang.String sIdent, java.lang.String sDelim) throws java.lang.IllegalStateException
Get an XML dump for the DBPersist values
sIdent
- Number of blank spaces for left padding at every line.sDelim
- Line delimiter (usually "\n" or "\r\n")java.lang.IllegalStateException
public java.lang.String toXML(java.lang.String sIdent)
Get an XML dump for the DBPersist values.
Lines are delimited by a single Line Feed CHR(10) '\n' character.
sIdent
- Number of blank spaces for left padding at every line.public java.lang.String toXML()
Get an XML dump for the DBPersist values.
No left padding is placed to the left of each line.
Lines are delimited by a single Line Feed CHR(10) '\n' character.
public void parseXML(java.lang.String sXMLFilePath) throws org.xml.sax.SAXException, org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException, org.xml.sax.SAXParseException, java.io.IOException, java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException
Load an XML String into DBPersist internal collection.
Each tag
Example of input file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ACLUser>
<gu_user>32f4f56fda343a5898c15a021203dd82</gu_user>
<id_domain>1026</id_domain>
<nm_user>The 7th Guest</nm_user>
<tx_pwd>123456</tx_pwd>
<tx_main_email>guest7@domain.com</tx_main_email>
<tx_alt_email>admin@hipergate.com</tx_alt_email>
<dt_last_updated>Fri, 29 Aug 2003 13:30:00 GMT+0130</dt_last_updated>
<tx_comments><![CDATA[Sôme ñasti & ïnternational chars stuff]]></tx_comments>
</ACLUser>
sXMLFilePath
- XML Path to XML file to parseorg.xml.sax.SAXException
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException
org.xml.sax.SAXParseException
java.io.IOException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException