ActiveObjects datetime with full precision in MySQL

I can create a java.util.Date field in an Active Objects Entity like this:

@Table("EXAMPLE")
public interface Example extends Entity {
    Date getExampleField();
    void setExampleField(Date exampleField);
}

Based on this ancient piece of Active Objects documentation, this will create a timestamp on Postgres, and on MySQL, will create a datetime. This is also what I see in testing.

Based on the MySQL documentation, by default datetime’s drop millisecond precision:

The fsp value, if given, must be in the range 0 to 6. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0. (This differs from the standard SQL default of 6, for compatibility with previous MySQL versions.)

This is also what I see in testing.

However, internal Confluence tables (on MySQL) use datetime(6), so if I use a Confluence API to get the timestamp of, for instance, when a page was modified, store it in an ActiveObjects table, then try to correlate my ActiveObjects entity with the same Confluence API, I can’t do it because I’ve lose the millisecond precision.

There exists the @StringLength annotation for changing the length of varchar columns, but I can’t find a similar thing for specifying to the precision (fsp) for MySQL datetimes.

Are there any options for me to store a timestamp with the same precision that the internal Confluence table uses without using a String field in my Entity?

4 Likes

We looked at the Active Objects source more closely, and did not find anything. Huge bummer, given that Atlassian all but forces plugin authors to use ActiveObjects for creating tables.