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 * An alternative to using this annotation would be to use insertable=false, 013 * updateable=false with @Column and have the DB insert the current time 014 * (default value on the DB column is SYSTIME etc). 015 * </p> 016 * <p> 017 * The downside to this approach is that the inserted entity does not have the 018 * timestamp value after the insert has occurred. You need to fetch the entity 019 * back to get the inserted timestamp if you want to used it. 020 * </p> 021 * 022 * <h3>Example:</h3> 023 * <pre>{@code 024 * 025 * @CreatedTimestamp 026 * Timestamp whenCreated; 027 * 028 * }</pre> 029 */ 030@Target({ ElementType.FIELD, ElementType.METHOD }) 031@Retention(RetentionPolicy.RUNTIME) 032public @interface CreatedTimestamp { 033 034}