File tree Expand file tree Collapse file tree 3 files changed +20
-29
lines changed
main/java/org/rayjars/hibernate
test/java/org/rayjars/hibernate Expand file tree Collapse file tree 3 files changed +20
-29
lines changed Original file line number Diff line number Diff line change 2121import java .sql .ResultSet ;
2222import java .sql .SQLException ;
2323import java .sql .Types ;
24+ import java .util .Properties ;
2425
2526import org .hibernate .HibernateException ;
2627import org .hibernate .engine .spi .SessionImplementor ;
28+ import org .hibernate .usertype .DynamicParameterizedType ;
2729import org .hibernate .usertype .UserType ;
30+ import org .hibernate .usertype .DynamicParameterizedType .ParameterType ;
2831import org .postgresql .util .PGobject ;
2932
3033import com .fasterxml .jackson .annotation .JsonInclude ;
3942 *
4043 * @author Regis Leray
4144 */
42- public abstract class JacksonUserType implements UserType {
45+ public class JacksonUserType implements UserType , DynamicParameterizedType {
4346
4447 private static final int [] SQL_TYPES = { Types .JAVA_OBJECT };
48+ private Class returnedClass ;
4549
4650 @ Override
4751 public boolean equals (Object x , Object y ) throws HibernateException {
@@ -164,4 +168,18 @@ public int[] sqlTypes() {
164168 return SQL_TYPES ;
165169 }
166170
171+ @ Override
172+ public void setParameterValues (Properties parameters ) {
173+ final ParameterType reader = (ParameterType ) parameters .get (PARAMETER_TYPE );
174+
175+ if (reader != null ) {
176+ this .returnedClass = reader .getReturnedClass ();
177+ }
178+ }
179+
180+ @ Override
181+ public Class returnedClass () {
182+ return this .returnedClass ;
183+ }
184+
167185}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public class Item {
3535 @ Column (name = "name" )
3636 private String name ;
3737
38- @ Type (type = "org.rayjars.hibernate.LabelUserType " )
38+ @ Type (type = "org.rayjars.hibernate.JacksonUserType " )
3939 @ Column (name = "label" )
4040 private Label label ;
4141
You can’t perform that action at this time.
0 commit comments