Top Description Methods
org.hibernate.annotations

public @Interface ColumnTransformer

extends Annotation
Annotations
@Target:FIELD, METHOD
@Retention:RUNTIME
@Repeatable:ColumnTransformers
Imports
java.lang.annotation.Repeatable, .Retention, .Target

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:

@Column(name="credit_card_num")
@ColumnTransformer(read="decrypt(credit_card_num)"
                   write="encrypt(?)")
String creditCardNumber;

A column transformer 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 insert or update by annotating the persistent attribute @Generated(event={INSERT,UPDATE}, writable=true). This results in a SQL select after every insert or update.

Author
Emmanuel Bernard
See Also
ColumnTransformers

Method Summary

Modifier and TypeMethod and Description
public String
forColumn()

The name of the mapped column, if a persistent attribute maps to multiple columns.

public String
read()

A custom SQL expression used to read from the column.

public String
write()

A custom SQL expression used to write to the column.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

forColumnback to summary
public String forColumn()

The name of the mapped column, if a persistent attribute maps to multiple columns. Optional if a persistent attribute is mapped to a single column

readback to summary
public String read()

A custom SQL expression used to read from the column.

writeback to summary
public String write()

A custom SQL expression used to write to the column. The expression must contain exactly one JDBC-style '?' placeholder.