19
19
import java .util .*;
20
20
21
21
public class JsonListType implements UserType , DynamicParameterizedType {
22
- private static final int [] SQL_TYPES = new int []{Types .LONGVARCHAR };
23
22
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper ();
24
23
private JavaType valueType = null ;
25
24
private Class <?> classType = null ;
@@ -44,24 +43,6 @@ public int hashCode(Object x) throws HibernateException {
44
43
return Objects .hashCode (x );
45
44
}
46
45
47
- @ Override
48
- public Object nullSafeGet (
49
- ResultSet resultSet ,
50
- int i ,
51
- SharedSessionContractImplementor sharedSessionContractImplementor ,
52
- Object o
53
- ) throws SQLException {
54
- try {
55
- String json = resultSet .getString (i );
56
- if (json == null ) {
57
- return null ;
58
- }
59
- return OBJECT_MAPPER .readValue (json , valueType );
60
- } catch (IOException e ) {
61
- throw new SQLException ("Exception deserializing JSON" , e );
62
- }
63
- }
64
-
65
46
@ Override
66
47
public void nullSafeSet (
67
48
PreparedStatement st ,
@@ -72,21 +53,28 @@ public void nullSafeSet(
72
53
nullSafeSet (st , value , index );
73
54
}
74
55
75
- public Object nullSafeGet (ResultSet rs , String [] names , Object owner ) throws HibernateException , SQLException {
76
- String value = rs .getString (names [0 ]).replace ("\" value\" " , "" ).replace ("{:" , "" ).replace ("}" , "" );
77
- Object result = null ;
78
- if (valueType == null ) {
79
- throw new HibernateException ("Value type not set." );
80
- }
81
- if (value != null && !value .equals ("" )) {
82
- try {
83
- result = OBJECT_MAPPER .readValue (value , valueType );
84
- } catch (IOException e ) {
85
- throw new HibernateException ("Exception deserializing value " + value , e );
86
- }
87
- }
88
- return result ;
89
- }
56
+ @ Override
57
+ public Object nullSafeGet (
58
+ ResultSet resultSet ,
59
+ int index ,
60
+ SharedSessionContractImplementor session ,
61
+ Object owner
62
+ ) throws HibernateException , SQLException {
63
+
64
+ String value = resultSet .getString (index ).replace ("\" value\" " , "" ).replace ("{:" , "" ).replace ("}" , "" );
65
+ Object result = null ;
66
+ if (valueType == null ) {
67
+ throw new HibernateException ("Value type not set." );
68
+ }
69
+ if (value != null && !value .equals ("" )) {
70
+ try {
71
+ result = OBJECT_MAPPER .readValue (value , valueType );
72
+ } catch (IOException e ) {
73
+ throw new HibernateException ("Exception deserializing value " + value , e );
74
+ }
75
+ }
76
+ return result ;
77
+ }
90
78
91
79
public void nullSafeSet (PreparedStatement st , Object value , int index ) throws HibernateException , SQLException {
92
80
StringWriter sw = new StringWriter ();
0 commit comments