Class SQLMap
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassUsed to build the where statement as a builder patternstatic enum -
Method Summary
Modifier and TypeMethodDescriptionstatic SQLMapCreates an SQL Map instance to the given database instancebooleanCreates a table matching the given property component if one doesn't exist yetvoidDeletes a table row matching the componentvoidDrop a table matching the given property componentgetColumnName(PropertyBase prop) By default the column name matches the property name unless explicitly modified with this methodReturns the SQL type for the given columnBy default the table name matches the property index name unless explicitly modified with this methodvoidAdds a new business object into the databaseselect(PropertyBusinessObject cmp, Property orderBy, boolean ascending, int maxElements, int page) Fetches the components from the database matching the given cmp description, the fields that aren't null within the cmp will match the where clauseFetches the components from the database matching the given select builder queryselectNot(PropertyBusinessObject cmp, Property orderBy, boolean ascending, int maxElements, int page) Fetches the components from the database matching the given cmp description, the fields that aren't null within the cmp will NOT match the where clausevoidsetColumnName(PropertyBase prop, String name) By default the column name matches the property name unless explicitly modified with this methodvoidsetPrimaryKey(PropertyBusinessObject cmp, Property pk) Sets the primary key for the componentvoidSets the primary key for the component and makes it auto-incrementvoidsetSqlType(PropertyBase p, SQLMap.SqlType type) Sets the sql type for the columnvoidsetTableName(PropertyBusinessObject cmp, String name) By default the table name matches the property index name unless explicitly modified with this methodvoidsetVerbose(boolean verbose) Toggle verbose modevoidThe equivalent of an SQL update assumes that the object is already in the database
-
Method Details
-
create
-
setPrimaryKey
Sets the primary key for the component
Parameters
-
cmp: the business object -
pk: the primary key field
-
-
setPrimaryKeyAutoIncrement
Sets the primary key for the component and makes it auto-increment
Parameters
-
cmp: the business object -
pk: the primary key field
-
-
setSqlType
Sets the sql type for the column
Parameters
-
p: the property -
type: one of the enum values representing supported SQL data types
-
-
getSqlType
Returns the SQL type for the given column
Parameters
p: the property
Returns
the sql data type
-
setTableName
By default the table name matches the property index name unless explicitly modified with this method
Parameters
-
cmp: the properties business object -
name: the name of the table
-
-
getTableName
By default the table name matches the property index name unless explicitly modified with this method
Parameters
cmp: the properties business object
Returns
the name of the table
-
setColumnName
By default the column name matches the property name unless explicitly modified with this method
Parameters
-
prop: a property instance, this will apply to all the property instances for the type -
name: the name of the column
-
-
getColumnName
By default the column name matches the property name unless explicitly modified with this method
Parameters
prop: a property instance, this will apply to all the property instances for the type
Returns
the name of the property
-
createTable
Creates a table matching the given property component if one doesn't exist yet
Parameters
cmp: the business object
Returns
true if the table was created false if it already existed
- Throws:
IOException
-
dropTable
Drop a table matching the given property component
Parameters
cmp: the business object
- Throws:
IOException
-
insert
Adds a new business object into the database
Parameters
cmp: the business component
- Throws:
IOException
-
update
The equivalent of an SQL update assumes that the object is already in the database
Parameters
cmp: the component
Throws
IOException
- Throws:
IOException
-
delete
Deletes a table row matching the component
Parameters
cmp: the component
- Throws:
IOException
-
select
public List<PropertyBusinessObject> select(PropertyBusinessObject cmp, Property orderBy, boolean ascending, int maxElements, int page) throws IOException, InstantiationException Fetches the components from the database matching the given cmp description, the fields that aren't null within the cmp will match the where clause
Parameters
-
cmp: the component to match -
orderBy: the column to order by, can be null to ignore order -
ascending: true to indicate ascending order -
maxElements: the maximum number of elements returned can be 0 or lower to ignore -
page: the page within the query to match the max elements value
Returns
the result of the query
- Throws:
IOExceptionInstantiationException
-
-
selectNot
public List<PropertyBusinessObject> selectNot(PropertyBusinessObject cmp, Property orderBy, boolean ascending, int maxElements, int page) throws IOException, InstantiationException Fetches the components from the database matching the given cmp description, the fields that aren't null within the cmp will NOT match the where clause
Parameters
-
cmp: the component to match -
orderBy: the column to order by, can be null to ignore order -
ascending: true to indicate ascending order -
maxElements: the maximum number of elements returned can be 0 or lower to ignore -
page: the page within the query to match the max elements value
Returns
the result of the query
- Throws:
IOExceptionInstantiationException
-
-
selectBuild
Fetches the components from the database matching the given select builder query
Returns
the result of the query
-
setVerbose
public void setVerbose(boolean verbose) Toggle verbose mode
Parameters
verbose
-