All Packages Class Hierarchy This Package Previous Next Index
Class JBMSTours.serializabletypes.Person
java.lang.Object
|
+----JBMSTours.serializabletypes.Person
- public class Person
- extends Object
- implements Externalizable
Look at the Source.
A Person is stored in the person column of the People table.
Usually only subclasses (Adult and Child) are stored.
A Person is a member of a Group.
These classes illustrate how you can
store instances of subclasses in a column defined to store
the superclass. (In reality, these classes are probably too
simple to store as objects--probably it is better to store the fields
as simple data types.)x
Cloudscape automatically assigns the integer value in the person_id column
(DEFAULT AUTOINCREMENT) whenever a row is inserted. This class uses the
updatePersonWithAutoincrementValue
method to find out what that value was and then to update the Person object to
assign that value to this.id
.
BuildATour constructs the Persons.
- See Also:
- Adult, Child, Group, BuildATour
-
birthdate
-
-
firstName
-
-
id
-
-
lastName
-
-
middleInitial
-
-
serialVersionUID
-
-
Person()
-
-
Person(String, String)
- Constructor.
-
Person(String, String, char)
- Constructor.
-
equals(Object)
- Good Cloudscape practice requires that objects override
equals and hashCode so that = and <> operators work correctly
in SQL comparisons.
-
findPerson(Connection, int)
- Queries the People table to return the appropriate person
object based on the person's id.
-
getAge()
- Gets the age.
-
getFirstName()
- Gets the first name.
-
getId()
- Gets the person's ID.
-
getLastName()
- Gets the last name.
-
getName()
- Gets the full name.
-
hashCode()
- Good Cloudscape practice requires that objects override
equals and hashCode so that = and <> operators work correctly
in SQL comparisons.
-
parentInTable(Connection)
- Is the child's parent already in the table.
-
prepareStaticStatements(Connection)
-
-
printName()
- Does a system out of the name.
-
readExternal(ObjectInput)
-
-
setBirthdate(Date)
- Sets the person's age.
-
setId(int)
- Sets the person's ID.
-
toString()
- Returns getName()
-
updatePersonWithAutoincrementValue(Connection)
- Get info about the last AUTOINCREMENT value inserted into the People table,
and assign that number to the Person object inserted in the same row,
and also return the new (updated) Person object.
-
writeExternal(ObjectOutput)
-
id
public int id
firstName
protected String firstName
lastName
protected String lastName
middleInitial
protected char middleInitial
birthdate
protected Date birthdate
serialVersionUID
public static final long serialVersionUID
Person
public Person()
Person
public Person(String first,
String last)
- Constructor.
Takes a first name and a last name.
- Parameters:
- first - the first name.
- last - the last name.
Person
public Person(String first,
String last,
char a)
- Constructor.
Takes a first name, a last name, and a middle initial.
- Parameters:
- first - thefirst name.
- last - the last name.
- a - the middle initial.
setBirthdate
public void setBirthdate(Date bd)
- Sets the person's age.
- Parameters:
- bd - birth date.
getName
public String getName()
- Gets the full name.
getFirstName
public String getFirstName()
- Gets the first name.
getLastName
public String getLastName()
- Gets the last name.
prepareStaticStatements
public static boolean prepareStaticStatements(Connection conn) throws SQLException
printName
public void printName()
- Does a system out of the name.
setId
public void setId(int i)
- Sets the person's ID.
- Parameters:
- i - the ID.
getId
public int getId()
- Gets the person's ID.
- Returns:
- int The ID.
getAge
public int getAge()
- Gets the age.
toString
public String toString()
- Returns getName()
- Overrides:
- toString in class Object
findPerson
public static Person findPerson(Connection conn,
int personId) throws SQLException
- Queries the People table to return the appropriate person
object based on the person's id.
- Parameters:
- conn - Connection
- personId - id of person
- Returns:
- Person object
- Throws: SQLException
- Thrown if there is a SQL error.
updatePersonWithAutoincrementValue
public void updatePersonWithAutoincrementValue(Connection conn) throws SQLException
- Get info about the last AUTOINCREMENT value inserted into the People table,
and assign that number to the Person object inserted in the same row,
and also return the new (updated) Person object. It is expected that you would
call this method after inserting a person into the database.
- Parameters:
- conn - the connection to the database.
- Returns:
- the Person object updated with its id (that Person object is also updated
in the database during this method).
- Throws: SQLException
- thrown if database access fails.
parentInTable
public boolean parentInTable(Connection conn) throws SQLException
- Is the child's parent already in the table. (Used in a check
constraint.)
- Parameters:
- conn - Connection
- Returns:
- boolean if parent is in table.
- Throws: SQLException
- Thrown if there is a SQL error.
equals
public boolean equals(Object o)
- Good Cloudscape practice requires that objects override
equals and hashCode so that = and <> operators work correctly
in SQL comparisons.
- Parameters:
- Object - object to compare it to
- Returns:
- boolean if the objects are equal
- Overrides:
- equals in class Object
hashCode
public int hashCode()
- Good Cloudscape practice requires that objects override
equals and hashCode so that = and <> operators work correctly
in SQL comparisons.
- Parameters:
- Object - object to compare it to
- Returns:
- boolean if the objects are equal
- Overrides:
- hashCode in class Object
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
All Packages Class Hierarchy This Package Previous Next Index