Database Access Specifications
System Specifications:
The JAVA Object Engine is a specification for Object-oriented access to JAVA database objects.
The objectives of this specification are:
Cat cat = new Cat();Adding records:
cat.addNew(); cat.name.setText("Siamese"); cat.color.setText("Beige"); cat.weight.setWeightRange(AnimalWeight.kLight); cat.add(); System.out.println("Added Siamese");
cat.addNew(); cat.name.setText("Tabby"); cat.color.setText("Black and White"); cat.weight.setWeightRange(AnimalWeight.kLight); cat.add(); System.out.println("Added Tabby");
Dog dog = new Dog(); dog.addNew(); dog.name.setText("German Saint Bernard"); dog.color.setText("Gray"); dog.weight.setWeightRange(AnimalWeight.kHeavy); dog.bark.setText("Loud"); dog.add(); System.out.println("Added Saint Bernard");
dog.addNew(); dog.name.setText("Poodle"); dog.color.setText("White"); dog.weight.setWeightRange(AnimalWeight.kLight); dog.bark.setText("Sharp"); dog.add(); System.out.println("Added Poodle");Simple sequential processing:
while (cat.hasNext()) { cat.next(); System.out.println(cat.toString()); }simple keyed retrieval
cat.name.setText("Tabby"); cat = cat.get(); if (cat != null) System.out.println(cat.toString());abstract sequential class:
class Animal { public int getDatabaseType() { // This tells the table that this is a merge query return DBConstants.kVector | DBConstants.kBaseTableClass; } public void addTables() { this.addTable(new Cat(null)); this.addTable(new Dog(null)); } }abstract sequential processing:
Animal animal = new Animal(); Table animalTable = animal.getTable(); animalTable.setKeyArea(animal.name); int i = 0; while (animalTable.hasNext()) { animal = (Animal)animalTable.move(+1); System.out.println(animal); iCount++; }keyed retrieval using a field
cat = catIDField.getReference();multiple collection processing (joins):
Using a query:
class AnimalVets extends QueryRecord { public AnimalVets() {}
public String getTableNames(boolean bAddQuotes) { return "AnimalVets"; // Only supply this if your SQL versions have an embedded query! } public addTables() { this.addTable(new Animal()); this.addTable(new Vets()); } public setupRelationships() { this.addRelationship(DBConstants.kLeftInner, animals.getField(vetID), vets.getField(vetID)); } public selectFields() { this.selectField(animals.name); this.selectField(animals.vetID); this.selectField(vets.vetID); this.selectField(vets.name); } }Using a behavior:
cat.addBehavior(new ReadSecondaryBehavior(vet)); // Anytime a cat is read, the vet is readFor abstract files:
animal.addBehavior(new ReadSecondaryBehavior(vet)); // Anytime a cat is read, the vet is readsub-file sequential processing
cat.addBehavior(new SubFileBehavior(vet)); // Sequential processing of cats only for the current vetFor abstract files:
animal.addBehavior(new SubFileBehavior(vet)); // Sequential processing of cats only for the current vet