All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avaje.ebean.annotation.DbEnumValue Maven / Gradle / Ivy

package com.avaje.ebean.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Specify a method on an Enum that returns the value that should be stored in the DB.
 * 

* This is the preferred option for mapping Enum's to DB values (preferred over the JPA * standard @Enumerated and Ebean's @EnumValue annotations). *

*

Example:

*
{@code
 *
 *   public enum Status {
 *     NEW("N"),
 *     ACTIVE("A"),
 *     INACTIVE("I");
 *
 *     String dbValue;
 *     Status(String dbValue) {
 *       this.dbValue = dbValue;
 *     }
 *
 *     @DbEnumValue
 *     public String getValue() {
 *       return dbValue;
 *     }
 *   }
 *
 * }
*/ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface DbEnumValue { /** * Specify the database type used to store the values (VARCHAR or INTEGER). */ DbEnumType storage() default DbEnumType.VARCHAR; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy