-
Notifications
You must be signed in to change notification settings - Fork 6
"Mapping" an Object to a Table
kremerk edited this page Jan 12, 2012
·
1 revision
- Create a Java Object (POJO style) with fields, and getters/setters that follow the POJO convention:
- getters and setters work like getXXXX and setXXXX where XXXX = the field name with a capital first letter
- boolean getters follow the "is" convention, so a boolean would be setXXXX and isXXXX.
- The Object's name matches a table in the database. The database's table name should be an all lowercase version of the Java Object
That's it!
Example:
public class User {
private String name;
private String password;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
Would map to a database table that looks like this, with the name of user:
column name | type |
---|---|
name | text |
password | text |