Java Reference
In-Depth Information
public void removePost(Post post) throws RemoteException, RemoveException
for (int i = 0; i < posts.size(); i++) {
Post thisPost = (Post)posts.elementAt(i);
if (thisPost.isIdentical(post)) {
Here, we remove a post from the discussion. We find the post by iterating
through the vector. We then remove it, break, and return. You can find a com-
plete version of the class at http: //
The bean class for Post
The PostBean class is full of primarily getters and setters, so it's not as interest-
ing as the earlier ones. To illustrate the concept, we'll show an attribute and
the associated accessors:
public String author;
public java.lang.String getAuthor() {
return author;
public void setAuthor(java.lang.String newValue) { = newValue;
This entity bean is a leaf node in our database. It doesn't have any additional
collections; thus, the implementation is fairly bland. The container does
almost everything for us, after some simple housekeeping. Again, you can find
a complete version of the class at http: //
Defining the primary key
Let's look at the primary key class for boardBean . The primary key class helps
to identify the database fields that represent a true database primary key, which
is a set of fields used to uniquely identify a row in a table. We'll see the defini-
tions of equality, and as good citizens, whenever we override equality, we also
should override hash code:
package com.bitterjava.bbs.ejb;
public class BoardKey implements {
public java.lang.String name;
final static long serialVersionUID = 3206093459760846163L;
Search WWH ::

Custom Search