| 4 | |
| 5 | The code for creating the empty annotations go something like this (assuming that we have an annotatable item and an annotation type): |
| 6 | {{{ |
| 7 | Annotatable item = ... |
| 8 | AnnotationType at = ... |
| 9 | AnnotationSet as = item.getAnnotationSet(); |
| 10 | Annotation a = as.getAnnotation(at); // <-The empty annotation is created here |
| 11 | |
| 12 | // a.setValue(aValue) must be called to create a non-empty annotation |
| 13 | |
| 14 | dc.commit(); // <- We must check that annotation values has been set here |
| 15 | }}} |
| 16 | |
| 17 | The annotation information is spread out over multiple database tables. If the `Annotation.setValue()` method is called to set the annotation, here is what happens: |
| 18 | |
| 19 | * An entry in the `Annotations` table is created |
| 20 | * An entry in the `ParameterValues` table is created |
| 21 | * An entry in the actual data table is created. The actual table depends on the data type. For example `StringValues` for string annotations or `IntegerValues` for integer annotations. |
| 22 | |
| 23 | If the `Annotation.setValue()` method is not called only the first two entries are created but not the third. This can result in some strange behavior in other places since if an annotation entry exists it is expected to have at least one value. |