next up previous contents
Next: Complex Storage and Heavy Up: Storing in the Database Previous: Simple storage   Contents

Naming Conventions

At this point running MapToJava with the options -factories and '-schema file-name' will create the usual java files and in the same packages as each file create a Factory. The naming convention is Abstractfile-nameFactory.java : so User.java would be accompanied by AbstractUserFactory.java.

The abstract factory contains a listing of all the java/sql field mappings, the table name, and pre-coded insert, update, and delete strings. Abstract routines from FactoryBase like (getTableName(), etc.) are implemented.3.8 Also found are the names of the generated stored procedure name and how to call it (if the '-procs' switch was used in generation). The methods getByOid, and store are also implmented.

The next step is the declared factory. One needs to define a factory (usually class-nameFactory), to extend the abstract Factory and implement any methods you need. To UserFactory we would write any desired queries as follows.

	public User getUserById (DatabaseSession dbSess, String id) throws
SQLException {
		return (User)super.getObject (dbSess, super.userId, id);
	}
It's that simple.

2002-03-05