Author: epbernard
Date: 2010-09-29 05:44:15 -0400 (Wed, 29 Sep 2010)
New Revision: 20748
Added:
core/trunk/core/src/main/java/org/hibernate/annotations/ColumnTransformer.java
core/trunk/core/src/main/java/org/hibernate/annotations/ColumnTransformers.java
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ColumnTransformerTest.java
Removed:
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpression.java
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpressions.java
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ReadWriteExpressionTest.java
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/Ejb3Column.java
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/Staff.java
Log:
HHH-4510 Rename @ReadWriteExpression to @ColumnTransformer
It relates to the ResultTransformer we have but at the column level
Copied: core/trunk/core/src/main/java/org/hibernate/annotations/ColumnTransformer.java
(from rev 20747,
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpression.java)
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/annotations/ColumnTransformer.java
(rev 0)
+++
core/trunk/core/src/main/java/org/hibernate/annotations/ColumnTransformer.java 2010-09-29
09:44:15 UTC (rev 20748)
@@ -0,0 +1,61 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors
as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.annotations;
+
+import java.lang.annotation.Retention;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Custom SQL expression used to read the value from and write a value to a column.
+ * Use for direct object loading/saving as well as queries.
+ * The write expression must contain exactly one '?' placeholder for the value.
+ *
+ * For example: <code>read="decrypt(credit_card_num)"
write="encrypt(?)"</code>
+ *
+ * @author Emmanuel Bernard
+ */
+(a)java.lang.annotation.Target({FIELD,METHOD})
+@Retention(RUNTIME)
+public @interface ColumnTransformer {
+ /**
+ * (Logical) column name for which the expression is used
+ *
+ * This can be left out if the property is bound to a single column
+ */
+ String forColumn() default "";
+
+ /**
+ * Custom SQL expression used to read from the column
+ */
+ String read() default "";
+
+ /**
+ * Custom SQL expression used to write to the column.
+ * The write expression must contain exactly one '?' placeholder for the value.
+ */
+ String write() default "";
+}
Copied: core/trunk/core/src/main/java/org/hibernate/annotations/ColumnTransformers.java
(from rev 20747,
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpressions.java)
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/annotations/ColumnTransformers.java
(rev 0)
+++
core/trunk/core/src/main/java/org/hibernate/annotations/ColumnTransformers.java 2010-09-29
09:44:15 UTC (rev 20748)
@@ -0,0 +1,42 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors
as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.annotations;
+
+import java.lang.annotation.Retention;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Plural annotation for @ColumnTransformer.
+ * Useful when more than one column is using this behavior.
+ *
+ * @author Emmanuel Bernard
+ */
+(a)java.lang.annotation.Target({FIELD,METHOD})
+@Retention(RUNTIME)
+public @interface ColumnTransformers {
+ ColumnTransformer[] value();
+}
Deleted: core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpression.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpression.java 2010-09-29
09:42:52 UTC (rev 20747)
+++
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpression.java 2010-09-29
09:44:15 UTC (rev 20748)
@@ -1,59 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors
as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.annotations;
-
-import java.lang.annotation.Retention;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Custom SQL expression used to read the value from and write a value to a column.
- * Use for direct object loading/saving as well as queries.
- * The write expression must contain exactly one '?' placeholder for the value.
- *
- * For example: <code>read="decrypt(credit_card_num)"
write="encrypt(?)"</code>
- *
- * @author Emmanuel Bernard
- */
-(a)java.lang.annotation.Target({FIELD,METHOD})
-@Retention(RUNTIME)
-public @interface ReadWriteExpression {
- /**
- * (Logical) column name for which the expression is used
- */
- String forColumn() default "";
-
- /**
- * Custom SQL expression used to read from the column
- */
- String read() default "";
-
- /**
- * Custom SQL expression used to write to the column.
- * The write expression must contain exactly one '?' placeholder for the value.
- */
- String write() default "";
-}
Deleted:
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpressions.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpressions.java 2010-09-29
09:42:52 UTC (rev 20747)
+++
core/trunk/core/src/main/java/org/hibernate/annotations/ReadWriteExpressions.java 2010-09-29
09:44:15 UTC (rev 20748)
@@ -1,42 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors
as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.annotations;
-
-import java.lang.annotation.Retention;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Plural annotation for @ReadWriteExpressions.
- * Useful when more than one column is using this behavior.
- *
- * @author Emmanuel Bernard
- */
-(a)java.lang.annotation.Target({FIELD,METHOD})
-@Retention(RUNTIME)
-public @interface ReadWriteExpressions {
- ReadWriteExpression[] value();
-}
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Ejb3Column.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Ejb3Column.java 2010-09-29 09:42:52
UTC (rev 20747)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Ejb3Column.java 2010-09-29 09:44:15
UTC (rev 20748)
@@ -27,9 +27,9 @@
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
+import org.hibernate.annotations.ColumnTransformer;
+import org.hibernate.annotations.ColumnTransformers;
import org.hibernate.annotations.Index;
-import org.hibernate.annotations.ReadWriteExpression;
-import org.hibernate.annotations.ReadWriteExpressions;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.annotations.Nullability;
import org.hibernate.mapping.Column;
@@ -483,10 +483,10 @@
if ( inferredData != null ) {
XProperty property = inferredData.getProperty();
if ( property != null ) {
- processExpression( property.getAnnotation( ReadWriteExpression.class ) );
- ReadWriteExpressions annotations = property.getAnnotation( ReadWriteExpressions.class
);
+ processExpression( property.getAnnotation( ColumnTransformer.class ) );
+ ColumnTransformers annotations = property.getAnnotation( ColumnTransformers.class );
if (annotations != null) {
- for ( ReadWriteExpression annotation : annotations.value() ) {
+ for ( ColumnTransformer annotation : annotations.value() ) {
processExpression( annotation );
}
}
@@ -494,7 +494,7 @@
}
}
- private void processExpression(ReadWriteExpression annotation) {
+ private void processExpression(ColumnTransformer annotation) {
String nonNullLogicalColumnName = logicalColumnName != null ? logicalColumnName :
""; //use the default for annotations
if ( annotation != null &&
( StringHelper.isEmpty( annotation.forColumn() )
Modified:
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml
===================================================================
---
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-09-29
09:42:52 UTC (rev 20747)
+++
core/trunk/documentation/manual/src/main/docbook/en-US/content/basic_mapping.xml 2010-09-29
09:44:15 UTC (rev 20748)
@@ -2225,8 +2225,8 @@
<classname>org.hibernate.annotations.SourceType.VM</classname> and
<classname>org.hibernate.annotations.SourceType.DB</classname>. The
default is <classname>SourceType.DB</classname> which is also used
in
- case there is no <classname>@Source</classname> annotation at all.
- </para>
+ case there is no <classname>@Source</classname> annotation at
+ all.</para>
<para>Like in the case of version numbers, the timestamp can also be
generated by the database instead of Hibernate. To do that, use
@@ -5782,7 +5782,7 @@
</section>
<section id="mapping-column-read-and-write" revision="1">
- <title>Column read and write expressions</title>
+ <title>Column transformers: read and write expressions</title>
<para>Hibernate allows you to customize the SQL it uses to read and write
the values of columns mapped to <link
@@ -5793,7 +5793,7 @@
<programlisting role="JAVA">@Entity
class CreditCard {
@Column(name="credit_card_num")
- @ReadWriteExpression(
+ @ColumnTransformer(
read="decrypt(credit_card_num)",
write="encrypt(?)")
public String getCreditCardNumber() { return creditCardNumber; }
@@ -5812,8 +5812,8 @@
<note>
<para>You can use the plural form
- <classname>@ReadWriteExpressions</classname> if more than one columns
- need to define either of these rules.</para>
+ <classname>@ColumnTransformers</classname> if more than one columns
need
+ to define either of these rules.</para>
</note>
<para>If a property uses more that one column, you must use the
@@ -5826,7 +5826,7 @@
@Columns( {
@Column(name="credit_card_num"),
@Column(name="exp_date") } )
- @ReadWriteExpression(
+ @ColumnTransformer(
forColumn="credit_card_num",
read="decrypt(credit_card_num)",
write="encrypt(?)")
Copied:
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ColumnTransformerTest.java
(from rev 20747,
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ReadWriteExpressionTest.java)
===================================================================
---
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ColumnTransformerTest.java
(rev 0)
+++
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ColumnTransformerTest.java 2010-09-29
09:44:15 UTC (rev 20748)
@@ -0,0 +1,89 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors
as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.various.readwriteexpression;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ColumnTransformerTest extends TestCase {
+
+ public void testCustomColumnReadAndWrite() throws Exception{
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ final double HEIGHT_INCHES = 73;
+ final double HEIGHT_CENTIMETERS = HEIGHT_INCHES * 2.54d;
+
+ Staff staff = new Staff(HEIGHT_INCHES, HEIGHT_INCHES, HEIGHT_INCHES*2, 1);
+ s.persist( staff );
+ s.flush();
+
+ // Test value conversion during insert
+ Double heightViaSql = (Double)s.createSQLQuery("select size_in_cm from t_staff
where t_staff.id=1").uniqueResult();
+ assertEquals(HEIGHT_CENTIMETERS, heightViaSql, 0.01d);
+
+ heightViaSql = (Double)s.createSQLQuery("select radiusS from t_staff where
t_staff.id=1").uniqueResult();
+ assertEquals(HEIGHT_CENTIMETERS, heightViaSql, 0.01d);
+
+ heightViaSql = (Double)s.createSQLQuery("select diamet from t_staff where
t_staff.id=1").uniqueResult();
+ assertEquals(HEIGHT_CENTIMETERS*2, heightViaSql, 0.01d);
+
+ // Test projection
+ Double heightViaHql = (Double)s.createQuery("select s.sizeInInches from Staff s
where s.id = 1").uniqueResult();
+ assertEquals(HEIGHT_INCHES, heightViaHql, 0.01d);
+
+ // Test restriction and entity load via criteria
+ staff = (Staff)s.createCriteria(Staff.class)
+ .add( Restrictions.between("sizeInInches", HEIGHT_INCHES - 0.01d,
HEIGHT_INCHES + 0.01d))
+ .uniqueResult();
+ assertEquals(HEIGHT_INCHES, staff.getSizeInInches(), 0.01d);
+
+ // Test predicate and entity load via HQL
+ staff = (Staff)s.createQuery("from Staff s where s.sizeInInches between ? and
?")
+ .setDouble(0, HEIGHT_INCHES - 0.01d)
+ .setDouble(1, HEIGHT_INCHES + 0.01d)
+ .uniqueResult();
+ assertEquals(HEIGHT_INCHES, staff.getSizeInInches(), 0.01d);
+
+ // Test update
+ staff.setSizeInInches(1);
+ s.flush();
+ heightViaSql = (Double)s.createSQLQuery("select size_in_cm from t_staff where
t_staff.id=1").uniqueResult();
+ assertEquals(2.54d, heightViaSql, 0.01d);
+ s.delete(staff);
+ t.commit();
+ s.close();
+ }
+
+ @Override
+ protected Class<?>[] getAnnotatedClasses() {
+ return new Class<?>[] {
+ Staff.class
+ };
+ }
+}
Deleted:
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ReadWriteExpressionTest.java
===================================================================
---
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ReadWriteExpressionTest.java 2010-09-29
09:42:52 UTC (rev 20747)
+++
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/ReadWriteExpressionTest.java 2010-09-29
09:44:15 UTC (rev 20748)
@@ -1,89 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors
as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.annotations.various.readwriteexpression;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.criterion.Restrictions;
-import org.hibernate.test.annotations.TestCase;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ReadWriteExpressionTest extends TestCase {
-
- public void testCustomColumnReadAndWrite() throws Exception{
- Session s = openSession();
- Transaction t = s.beginTransaction();
- final double HEIGHT_INCHES = 73;
- final double HEIGHT_CENTIMETERS = HEIGHT_INCHES * 2.54d;
-
- Staff staff = new Staff(HEIGHT_INCHES, HEIGHT_INCHES, HEIGHT_INCHES*2, 1);
- s.persist( staff );
- s.flush();
-
- // Test value conversion during insert
- Double heightViaSql = (Double)s.createSQLQuery("select size_in_cm from t_staff
where t_staff.id=1").uniqueResult();
- assertEquals(HEIGHT_CENTIMETERS, heightViaSql, 0.01d);
-
- heightViaSql = (Double)s.createSQLQuery("select radiusS from t_staff where
t_staff.id=1").uniqueResult();
- assertEquals(HEIGHT_CENTIMETERS, heightViaSql, 0.01d);
-
- heightViaSql = (Double)s.createSQLQuery("select diamet from t_staff where
t_staff.id=1").uniqueResult();
- assertEquals(HEIGHT_CENTIMETERS*2, heightViaSql, 0.01d);
-
- // Test projection
- Double heightViaHql = (Double)s.createQuery("select s.sizeInInches from Staff s
where s.id = 1").uniqueResult();
- assertEquals(HEIGHT_INCHES, heightViaHql, 0.01d);
-
- // Test restriction and entity load via criteria
- staff = (Staff)s.createCriteria(Staff.class)
- .add( Restrictions.between("sizeInInches", HEIGHT_INCHES - 0.01d,
HEIGHT_INCHES + 0.01d))
- .uniqueResult();
- assertEquals(HEIGHT_INCHES, staff.getSizeInInches(), 0.01d);
-
- // Test predicate and entity load via HQL
- staff = (Staff)s.createQuery("from Staff s where s.sizeInInches between ? and
?")
- .setDouble(0, HEIGHT_INCHES - 0.01d)
- .setDouble(1, HEIGHT_INCHES + 0.01d)
- .uniqueResult();
- assertEquals(HEIGHT_INCHES, staff.getSizeInInches(), 0.01d);
-
- // Test update
- staff.setSizeInInches(1);
- s.flush();
- heightViaSql = (Double)s.createSQLQuery("select size_in_cm from t_staff where
t_staff.id=1").uniqueResult();
- assertEquals(2.54d, heightViaSql, 0.01d);
- s.delete(staff);
- t.commit();
- s.close();
- }
-
- @Override
- protected Class<?>[] getAnnotatedClasses() {
- return new Class<?>[] {
- Staff.class
- };
- }
-}
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/Staff.java
===================================================================
---
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/Staff.java 2010-09-29
09:42:52 UTC (rev 20747)
+++
core/trunk/testsuite/src/test/java/org/hibernate/test/annotations/various/readwriteexpression/Staff.java 2010-09-29
09:44:15 UTC (rev 20748)
@@ -28,7 +28,7 @@
import javax.persistence.Id;
import javax.persistence.Table;
-import org.hibernate.annotations.ReadWriteExpression;
+import org.hibernate.annotations.ColumnTransformer;
/**
* @author Emmanuel Bernard
@@ -50,7 +50,7 @@
private Integer id;
@Column(name="size_in_cm")
- @ReadWriteExpression(
+ @ColumnTransformer(
forColumn = "size_in_cm",
read = "size_in_cm / 2.54",
write = "? * 2.54" )
@@ -59,7 +59,7 @@
private double sizeInInches;
//Weird extra S to avoid potential SQL keywords
- @ReadWriteExpression(
+ @ColumnTransformer(
read = "radiusS / 2.54",
write = "? * 2.54" )
public double getRadiusS() { return radiusS; }
@@ -67,7 +67,7 @@
private double radiusS;
@Column(name="diamet")
- @ReadWriteExpression(
+ @ColumnTransformer(
read = "diamet / 2.54",
write = "? * 2.54" )
public double getDiameter() { return diameter; }