diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformer.java b/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformer.java index 6131e33a67..ac05ef8736 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/ColumnTransformer.java @@ -14,19 +14,38 @@ import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; /** - * Specifies custom SQL expressions used to read and write to a column in all generated SQL - * involving the annotated persistent attribute. + * Specifies custom SQL expressions used to read and write to the column mapped by + * the annotated persistent attribute in all generated SQL involving the annotated + * persistent attribute. * * For example: *
- * {@code @Column(name="credit_card_num")
+ * {@code
+ * @Column(name="credit_card_num")
  * @ColumnTransformer(read="decrypt(credit_card_num)"
  *                    write="encrypt(?)")
- * String creditCardNumber;}
+ * String creditCardNumber;
+ * }
  * 
+ * A column transformer {@link #write} expression transforms the value of a persistent + * attribute of an entity as it is being written to the database. + * + * In the second scenario, we may ask Hibernate to resynchronize the in-memory state + * with the database after each {@code insert} or {@code update} by annotating the + * persistent attribute {@link Generated @Generated(value=ALWAYS, writable=true)}. + * This results in a SQL {@code select} after every {@code insert} or {@code update}. * * @see ColumnTransformers * @@ -43,13 +62,13 @@ public @interface ColumnTransformer { String forColumn() default ""; /** - * Custom SQL expression used to read from the column. + * A custom SQL expression used to read from the column. */ String read() default ""; /** - * Custom SQL expression used to write to the column. The expression must contain exactly - * one JDBC-style '?' placeholder. + * A custom SQL expression used to write to the column. The expression must contain + * exactly one JDBC-style '?' placeholder. */ String write() default ""; } diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java b/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java index ccdb252ca2..130b80731d 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/Generated.java @@ -61,6 +61,8 @@ public @interface Generated { *