test.tester.model.dao
Class Article

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

public class Article
extends java.lang.Object
implements MappedTable

This class, when instancied, is like a row of ARTICLE, 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 Article back, and you can also do joins (if the table has foreign keys).

Consider the following example to create a new Article in the database:

     Article article = new Article();

     article.setArticleId(new Integer(1));
     article.setTitle("test");
     article.setSubtitle("text example");
     article.setBody("text example");
     article.setDay("02-02-2002");
     article.setCategoryId(new Integer(1));
     article.setMemberId(new Integer(1));
     article.setSpecial(new Boolean(true));
     ... 

     article.save(); 
 
For selecting some rows, you can use the methods inside the ArticleBroker.ArticleBroker() class, which has a lot of static methods that return Collections of Article.

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_ARTICLE_ID
          Just a reference for the real SQL name of articleId
static java.lang.String FIELD_BODY
          Just a reference for the real SQL name of body
static java.lang.String FIELD_CATEGORY_ID
          Just a reference for the real SQL name of categoryId
static java.lang.String FIELD_DAY
          Just a reference for the real SQL name of day
static java.lang.String FIELD_MEMBER_ID
          Just a reference for the real SQL name of memberId
static java.lang.String FIELD_SPECIAL
          Just a reference for the real SQL name of special
static java.lang.String FIELD_SUBTITLE
          Just a reference for the real SQL name of subtitle
static java.lang.String FIELD_TITLE
          Just a reference for the real SQL name of title
static java.lang.String TABLE_ARTICLE
          Just a reference for the real SQL name of Article
 
Constructor Summary
Article()
          Dummy constructor.
Article(java.sql.ResultSet resultSet)
          Creates a new Article using the values from the current row of the given resultSet.
 
Method Summary
 void delete()
          Deletes this article.
 java.lang.Integer getArticleId()
          Gets the articleId.
 java.lang.String getBody()
          Gets the body.
 java.lang.Integer getCategoryId()
          Gets the categoryId.
 java.lang.String getDay()
          Gets the day.
 java.lang.Integer getMemberId()
          Gets the memberId.
 java.lang.Boolean getSpecial()
          Gets the special.
 java.lang.String getSubtitle()
          Gets the subtitle.
 java.lang.String getTitle()
          Gets the title.
 void save()
          Saves this article.
 void set(java.sql.ResultSet resultSet)
          Sets the content of this article, to the columns of the current row in the given resultSet.
 void setArticleId(java.lang.Integer articleId)
          Sets the articleId.
 void setBody(java.lang.String body)
          Sets the body.
 void setCategoryId(java.lang.Integer categoryId)
          Sets the categoryId.
 void setDay(java.lang.String day)
          Sets the day.
 void setMemberId(java.lang.Integer memberId)
          Sets the memberId.
 void setSpecial(java.lang.Boolean special)
          Sets the special.
 void setSubtitle(java.lang.String subtitle)
          Sets the subtitle.
 void setTitle(java.lang.String title)
          Sets the title.
 java.lang.String toString()
          Returns a structured string representation of this article.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TABLE_ARTICLE

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

See Also:
Constant Field Values

FIELD_ARTICLE_ID

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

See Also:
Constant Field Values

FIELD_TITLE

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

See Also:
Constant Field Values

FIELD_SUBTITLE

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

See Also:
Constant Field Values

FIELD_BODY

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

See Also:
Constant Field Values

FIELD_DAY

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

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_MEMBER_ID

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

See Also:
Constant Field Values

FIELD_SPECIAL

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

See Also:
Constant Field Values
Constructor Detail

Article

public Article()
Dummy constructor.


Article

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

Method Detail

getArticleId

public java.lang.Integer getArticleId()
Gets the articleId.


setArticleId

public void setArticleId(java.lang.Integer articleId)
Sets the articleId.


getTitle

public java.lang.String getTitle()
Gets the title.


setTitle

public void setTitle(java.lang.String title)
Sets the title.


getSubtitle

public java.lang.String getSubtitle()
Gets the subtitle.


setSubtitle

public void setSubtitle(java.lang.String subtitle)
Sets the subtitle.


getBody

public java.lang.String getBody()
Gets the body.


setBody

public void setBody(java.lang.String body)
Sets the body.


getDay

public java.lang.String getDay()
Gets the day.


setDay

public void setDay(java.lang.String day)
Sets the day.


getCategoryId

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


setCategoryId

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


getMemberId

public java.lang.Integer getMemberId()
Gets the memberId.


setMemberId

public void setMemberId(java.lang.Integer memberId)
Sets the memberId.


getSpecial

public java.lang.Boolean getSpecial()
Gets the special.


setSpecial

public void setSpecial(java.lang.Boolean special)
Sets the special.


save

public void save()
          throws DAOException
Saves this article. If the articleId 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 article. If the articleId 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 article, 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 article.

Overrides:
toString in class java.lang.Object