001package com.avaje.ebean.annotation;
002
003import java.lang.annotation.ElementType;
004import java.lang.annotation.Retention;
005import java.lang.annotation.RetentionPolicy;
006import java.lang.annotation.Target;
007
008/**
009 * For a timestamp property that is set to the datetime when the entity is
010 * created/inserted.
011 * <p>
012 * This is effectively an alias for @WhenCreated which was added as it hints
013 * towards a better naming convention (WhenCreated, WhenModified).
014 * </p>
015 * <p>
016 * An alternative to using this annotation would be to use insertable=false,
017 * updateable=false with @Column and have the DB insert the current time
018 * (default value on the DB column is SYSTIME etc).
019 * </p>
020 * <p>
021 * The downside to this approach is that the inserted entity does not have the
022 * timestamp value after the insert has occurred. You need to fetch the entity
023 * back to get the inserted timestamp if you want to used it.
024 * </p>
025 *
026 * <h3>Example:</h3>
027 * <pre>{@code
028 *
029 *   @CreatedTimestamp
030 *   Timestamp whenCreated;
031 *
032 * }</pre>
033 */
034@Target({ ElementType.FIELD, ElementType.METHOD })
035@Retention(RetentionPolicy.RUNTIME)
036public @interface CreatedTimestamp {
037
038}