@ -21,6 +21,10 @@ import java.lang.annotation.Retention;
@@ -21,6 +21,10 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy ;
import java.lang.annotation.Target ;
import javax.annotation.meta.When ;
import org.springframework.core.annotation.AliasFor ;
/ * *
* The annotation to configure a value object as embedded in the current table .
* < p / >
@ -38,6 +42,8 @@ public @interface Embedded {
@@ -38,6 +42,8 @@ public @interface Embedded {
/ * *
* Set the load strategy for the embedded object if all contained fields yield { @literal null } values .
* < p / >
* { @link Nullable @Embedded.Nullable } and { @link Empty @Embedded.Empty } offer shortcuts for this .
*
* @return never { @link } null .
* /
@ -57,4 +63,84 @@ public @interface Embedded {
@@ -57,4 +63,84 @@ public @interface Embedded {
enum OnEmpty {
USE_NULL , USE_EMPTY
}
/ * *
* Shortcut for a nullable embedded property .
*
* < pre >
* < code >
* & # 64 ; Embedded . Nullable
* private Address address ;
* < / code >
* < / pre >
*
* as alternative to the more verbose
*
* < pre >
* < code >
*
* & # 64 ; Embedded ( onEmpty = USE_NULL )
* & # 64 ; javax . annotation . Nonnull ( when = When . MAYBE )
* private Address address ;
*
* < / code >
* < / pre >
*
* @author Christoph Strobl
* @since 1 . 1
* @see Embedded # onEmpty ( )
* /
@Embedded ( onEmpty = OnEmpty . USE_NULL )
@Documented
@Retention ( RetentionPolicy . RUNTIME )
@Target ( { ElementType . FIELD , ElementType . METHOD } )
@javax.annotation.Nonnull ( when = When . MAYBE )
@interface Nullable {
/ * *
* @return prefix for columns in the embedded value object . An empty { @link String } by default .
* /
@AliasFor ( annotation = Embedded . class , attribute = "prefix" )
String prefix ( ) default "" ;
}
/ * *
* Shortcut for an empty embedded property .
*
* < pre >
* < code >
* & # 64 ; Embedded . Empty
* private Address address ;
* < / code >
* < / pre >
*
* as alternative to the more verbose
*
* < pre >
* < code >
*
* & # 64 ; Embedded ( onEmpty = USE_EMPTY )
* & # 64 ; javax . annotation . Nonnull ( when = When . NEVER )
* private Address address ;
*
* < / code >
* < / pre >
*
* @author Christoph Strobl
* @since 1 . 1
* @see Embedded # onEmpty ( )
* /
@Embedded ( onEmpty = OnEmpty . USE_EMPTY )
@Documented
@Retention ( RetentionPolicy . RUNTIME )
@Target ( { ElementType . FIELD , ElementType . METHOD } )
@javax.annotation.Nonnull ( when = When . NEVER )
@interface Empty {
/ * *
* @return prefix for columns in the embedded value object . An empty { @link String } by default .
* /
@AliasFor ( annotation = Embedded . class , attribute = "prefix" )
String prefix ( ) default "" ;
}
}