Default values

If a default is specified, the default value is used on both a new java object and as column default value in the sql script for the database. However, when a java object is saved, the database value is always overwritten because the normal behavior for saving a new object is to write all fields. This behavior can be overwritten by setting the column attribute useDatabaseDefaultValue to true. In this case, the column is not written on inserts if the value of the corresponding java field is equal to the default.
It is a good idea to have a non-primary key field in each table where useDatabaseDefaultValue is not set because otherwise you could run into SQL syntax errors when an unchanged new object is changed (because there are no values to insert).

One can use CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP as default for Date fields. Setting the attribute useDatabaseDefaultValue to false or not setting it makes Torque use the current java time as initial field value when constructing the object and saving it to the database, not considering the database default. Setting the attribute useDatabaseDefaultValue to true makes Torque setting the initial field value to null and using the database default when the object is first saved to the database.

MySQL table generation options

The following table create options can be set for MySQL using the option element inside the table element: ENGINE, AVG_ROW_LENGTH, CHARACTER SET, DEFAULT CHARACTER SET, CHECKSUM, COLLATE, DEFAULT COLLATE, CONNECTION, DATA DIRECTORY, DELAY_KEY_WRITE, INDEX DIRECTORY, INSERT_METHOD, KEY_BLOCK_SIZE, MAX_ROWS, MIN_ROWS, PACK_KEYS, PASSWORD, ROW_FORMAT, TABLESPACE, UNION, PARTITION BY

Example:

<table name="book">
  <option key="ENGINE" value="InnoDB"/>
  ...
</table>