net.java.ao.schema
Annotation Type OnUpdate


@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface OnUpdate

Specifies a value for the field to receive in the event of an UPDATE or INSERT statement in some other field of the corresponding row. This is most often used to implement a modified field, as it does not require manual re-specification of the update value in every place an UPDATE is performed.

The functionality of this annotation is modeled after the MySQL ON UPDATE field clause. However, because no other databases implement a similar syntax, triggers are often used as the implementation mechanism. Ironically, this means that most databases have a more flexible implementation of the functionality than MySQL. ActiveObjects performs no intrinsic checking to enforce limitations on the annotation's usage (for example, MySQL requires only one field with DEFAULT or ON UPDATE value equaling CURRENT_TIMESTAMP). This sort of checking is left entirely up to the database against which the migration is running.

Currently, this annotation is unsupported on HSQLDB due to the way it handles triggers. However, there is no hard limit actually preventing the functionality.

This annotation is only relevant to migrations. It has no effect upon "runtime" entity usage.

Author:
Daniel Spiewak

Required Element Summary
 String value
          Contains the database-agnostic representation of the default value for the corresponding field.
 

Element Detail

value

public abstract String value
Contains the database-agnostic representation of the default value for the corresponding field. The conversion between this String and the appropriate value is handled by the DatabaseType.defaultParseValue(String) method. Thus, even default values for custom types are supported.



Copyright © 2007-2011. All Rights Reserved.