test.tester.model.dao
Class Category

java.lang.Object
  |
  +--test.tester.model.dao.Category
All Implemented Interfaces:
MappedTable

public class Category
extends java.lang.Object
implements MappedTable

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:

     Category category = new Category();

     category.setCategoryId(new Integer(1));
     category.setName("test");
     category.setDescription("text example");
     ... 

     category.save(); 
 
For selecting some rows, you can use the methods inside the CategoryBroker.CategoryBroker() class, which has a lot of static methods that return Collections 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.

See Also:

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

TABLE_CATEGORY

public static final java.lang.String TABLE_CATEGORY
Just a reference for the real SQL name of Category

See Also:
Constant Field Values

FIELD_CATEGORY_ID

public static final java.lang.String FIELD_CATEGORY_ID
Just a reference for the real SQL name of categoryId

See Also:
Constant Field Values

FIELD_NAME

public static final java.lang.String FIELD_NAME
Just a reference for the real SQL name of name

See Also:
Constant Field Values

FIELD_DESCRIPTION

public static final java.lang.String FIELD_DESCRIPTION
Just a reference for the real SQL name of description

See Also:
Constant Field Values
Constructor Detail

Category

public Category()
Dummy constructor.


Category

public Category(java.sql.ResultSet resultSet)
         throws DAOException
Creates a new Category using the values from the current row of the given resultSet.

Method Detail

getCategoryId

public java.lang.Integer getCategoryId()
Gets the categoryId.


setCategoryId

public void setCategoryId(java.lang.Integer categoryId)
Sets the categoryId.


getName

public java.lang.String getName()
Gets the name.


setName

public void setName(java.lang.String name)
Sets the name.


getDescription

public java.lang.String getDescription()
Gets the description.


setDescription

public void setDescription(java.lang.String description)
Sets the description.


save

public void save()
          throws DAOException
Saves this 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.

Specified by:
save in interface MappedTable
DAOException

delete

public void delete()
            throws DAOException
Deletes this category. If the categoryId is null, that an exception is thrown.

Specified by:
delete in interface MappedTable
DAOException

set

public void set(java.sql.ResultSet resultSet)
         throws DAOException
Sets the content of this category, to the columns of the current row in the given resultSet.

Specified by:
set in interface MappedTable
DAOException

toString

public java.lang.String toString()
Returns a structured string representation of this category.

Overrides:
toString in class java.lang.Object