From 71d805bc17b20b21f4a10919bdf9c0b3659c8ba1 Mon Sep 17 00:00:00 2001 From: rbygrave Date: Sat, 30 May 2015 19:41:54 +1200 Subject: [PATCH] #302 - Postgres specific - Rename @ColumnHstore to @DbHstore (deprecate @ColumnHstore ) --- .../avaje/ebean/annotation/ColumnHstore.java | 4 ++- .../com/avaje/ebean/annotation/DbHstore.java | 26 +++++++++++++++++++ .../server/deploy/parse/AnnotationFields.java | 3 +++ .../deploy/parse/DeployCreateProperties.java | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/avaje/ebean/annotation/DbHstore.java diff --git a/src/main/java/com/avaje/ebean/annotation/ColumnHstore.java b/src/main/java/com/avaje/ebean/annotation/ColumnHstore.java index 0aa14360a..401afc188 100644 --- a/src/main/java/com/avaje/ebean/annotation/ColumnHstore.java +++ b/src/main/java/com/avaje/ebean/annotation/ColumnHstore.java @@ -6,8 +6,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * + * Deprecated - please use @DbHstore instead. + * @see DbHstore */ +@Deprecated @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ColumnHstore { diff --git a/src/main/java/com/avaje/ebean/annotation/DbHstore.java b/src/main/java/com/avaje/ebean/annotation/DbHstore.java new file mode 100644 index 000000000..38ce6bafd --- /dev/null +++ b/src/main/java/com/avaje/ebean/annotation/DbHstore.java @@ -0,0 +1,26 @@ +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; + +/** + * Used for mapping a Map type property to Postgres HSTORE data type. + *

+ * The Map property should have keys and values of type String. + *

+ * + *

Example:

+ *
{@code
+ *
+ *   @DbHstore
+ *   Map tags;
+ *
+ * }
+ */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface DbHstore { + +} \ No newline at end of file diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java index 64c9d2dbe..5f9ea7ad0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -146,6 +146,9 @@ public class AnnotationFields extends AnnotationParser { if (get(prop, ColumnHstore.class) != null) { util.setDbHstore(prop); } + if (get(prop, DbHstore.class) != null) { + util.setDbHstore(prop); + } Formula formula = get(prop, Formula.class); if (formula != null) { diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java index 470b7cb7c..cd907fe9f 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java +++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/DeployCreateProperties.java @@ -1,6 +1,7 @@ package com.avaje.ebeaninternal.server.deploy.parse; import com.avaje.ebean.annotation.ColumnHstore; +import com.avaje.ebean.annotation.DbHstore; import com.avaje.ebean.annotation.DbJson; import com.avaje.ebean.annotation.DbJsonB; import com.avaje.ebeaninternal.server.deploy.DetermineManyType; @@ -292,6 +293,7 @@ public class DeployCreateProperties { private boolean isMappedType(Field field) { return (field.getAnnotation(DbJson.class) != null) || (field.getAnnotation(DbJsonB.class) != null) + || (field.getAnnotation(DbHstore.class) != null) || (field.getAnnotation(ColumnHstore.class) != null); }