public class GenericRecord extends java.lang.Object implements Record
DBTable
and
DBColumns
can be persisted using GenericRecord
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
GETTER_NAME
default getter method indicator
|
static java.lang.String |
SETTER_NAME
default setter method indicator
|
WITH_BLOBS, WITHOUT_BLOBS
Constructor and Description |
---|
GenericRecord(java.lang.Class<?> c)
Create a new object of class GenericRecord
|
Modifier and Type | Method and Description |
---|---|
java.sql.PreparedStatement |
getDeleteStatment(java.sql.Connection c,
java.lang.Object record)
Get a statement suitable to delete a given object from the database
|
java.sql.PreparedStatement |
getInsertStatment(java.sql.Connection c,
java.lang.Object record)
Get a statement suitable to insert a given object to the database
|
java.sql.PreparedStatement |
getInsertStmt(java.sql.Connection c,
java.lang.Object record,
int autoGeneratedKeys)
Get a statement suitable to insert a given object to the database
|
java.lang.String |
getTableName()
Get the name of the database table this record references
|
java.sql.PreparedStatement |
getUpdateStatment(java.sql.Connection c,
java.lang.Object record)
Get a statement suitable to update a given object in the database
|
java.lang.Object |
toObject(java.sql.ResultSet resultSet,
boolean includeBlobs)
Get contents of this record as an object
|
public static final java.lang.String GETTER_NAME
public static final java.lang.String SETTER_NAME
public GenericRecord(java.lang.Class<?> c)
c
- the class to persistpublic java.sql.PreparedStatement getDeleteStatment(java.sql.Connection c, java.lang.Object record) throws java.lang.Exception
getDeleteStatment
in interface Record
c
- the database connection to use for the deleterecord
- the object to deletejava.lang.Exception
public java.sql.PreparedStatement getInsertStmt(java.sql.Connection c, java.lang.Object record, int autoGeneratedKeys) throws java.lang.Exception
getInsertStmt
in interface Record
c
- the database connection to use for the insertrecord
- the object to insertautoGeneratedKeys
- a flag indicating whether auto-generated keys should be returned;
one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYSjava.lang.Exception
public java.sql.PreparedStatement getInsertStatment(java.sql.Connection c, java.lang.Object record) throws java.lang.Exception
getInsertStatment
in interface Record
c
- the database connection to use for the insertrecord
- the object to insertjava.lang.Exception
public java.sql.PreparedStatement getUpdateStatment(java.sql.Connection c, java.lang.Object record) throws java.lang.Exception
getUpdateStatment
in interface Record
c
- the database connection to use for the updaterecord
- the object to updatejava.lang.Exception
public java.lang.Object toObject(java.sql.ResultSet resultSet, boolean includeBlobs) throws java.lang.Exception
public java.lang.String getTableName()
getTableName
in interface Record