Now let's create a simple persistent object.
We will just extend DBPersistentObject.

public class LibraryUser extends DBPersistentObject {

}

But that's not enough. We should implement the method define(), since DBPersistentObject is an abstract class. define() method is used to describe the fields of our persistent object.
Our object will have 4 data fields: (more fields will make our first example too complicated)
public class LibraryUser extends DBPersistentObject {
    public void define() {
        addField("FirstName"new VarcharField(50));
        addField("LastName"new VarcharField(50));
        addField("Age"new IntField());
        addField("Address"new VarcharField(100));
    }
}
The addField() method takes 2 arguments : field name and field type.
We used VarcharField - a class that implements a type corresponding to SQL VARCHAR(n).
IntField is another class that implements a type corresponding to SQL INT.
Almost all SQL standard types were implemented. Also notice that field names are joint. That's because the field name will be used as column name in the SQL table that holds our User objects.
And that's all. We can't see it in the browser, since this is not a panel - this is just a persistent object.

Previous page Tree of contents Next page