|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--test.tester.model.dao.Category
This class, when instancied, is like a row of CATEGORY
, creating
an object mapping into the database.
You can change its columns, then insert, update, delete...
You can do selects and get a Collection
of
Category
back, and you can also do
joins (if the table has foreign keys).
Consider the following example to create a new
Category
in the database:
For selecting some rows, you can use the methods inside theCategory category = new Category(); category.setCategoryId(new Integer(1)); category.setName("test"); category.setDescription("text example"); ... category.save();
CategoryBroker.CategoryBroker()
class, which has a lot of static methods
that return Collection
s of Category
.This persistence between the object and the database is not thread safe, this means that if you have a change in this row at the database, you will not get here, only if you reload it.
Field Summary | |
static java.lang.String |
FIELD_CATEGORY_ID
Just a reference for the real SQL name of categoryId |
static java.lang.String |
FIELD_DESCRIPTION
Just a reference for the real SQL name of description |
static java.lang.String |
FIELD_NAME
Just a reference for the real SQL name of name |
static java.lang.String |
TABLE_CATEGORY
Just a reference for the real SQL name of Category |
Constructor Summary | |
Category()
Dummy constructor. |
|
Category(java.sql.ResultSet resultSet)
Creates a new Category using the values from the current
row of the given resultSet. |
Method Summary | |
void |
delete()
Deletes this category . |
java.lang.Integer |
getCategoryId()
Gets the categoryId . |
java.lang.String |
getDescription()
Gets the description . |
java.lang.String |
getName()
Gets the name . |
void |
save()
Saves this category . |
void |
set(java.sql.ResultSet resultSet)
Sets the content of this category ,
to the columns of the current row in the given resultSet. |
void |
setCategoryId(java.lang.Integer categoryId)
Sets the categoryId . |
void |
setDescription(java.lang.String description)
Sets the description . |
void |
setName(java.lang.String name)
Sets the name . |
java.lang.String |
toString()
Returns a structured string representation of this category . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String TABLE_CATEGORY
public static final java.lang.String FIELD_CATEGORY_ID
public static final java.lang.String FIELD_NAME
public static final java.lang.String FIELD_DESCRIPTION
Constructor Detail |
public Category()
public Category(java.sql.ResultSet resultSet) throws DAOException
Category
using the values from the current
row of the given resultSet.
Method Detail |
public java.lang.Integer getCategoryId()
categoryId
.
public void setCategoryId(java.lang.Integer categoryId)
categoryId
.
public java.lang.String getName()
name
.
public void setName(java.lang.String name)
name
.
public java.lang.String getDescription()
description
.
public void setDescription(java.lang.String description)
description
.
public void save() throws DAOException
category
.
If the categoryId
is not null,
it will update it, otherwise it is a new record, then it will be inserted.Keep in mind that if you save it, and it is inserted, the primary key is NOT loaded, so if you save it again, another row will be inserted.
save
in interface MappedTable
DAOException
public void delete() throws DAOException
category
.
If the categoryId is null, that an exception is thrown.
delete
in interface MappedTable
DAOException
public void set(java.sql.ResultSet resultSet) throws DAOException
category
,
to the columns of the current row in the given resultSet.
set
in interface MappedTable
DAOException
public java.lang.String toString()
category
.
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |