private static Map<Type, GridType> createGridTypeConversionMap() { Map<Type, GridType> conversion = new HashMap<>(); conversion.put( StandardBasicTypes.CALENDAR, Iso8601StringCalendarType.DATE_TIME ); conversion.put( StandardBasicTypes.CALENDAR_DATE, Iso8601StringCalendarType.DATE ); conversion.put( StandardBasicTypes.DATE, Iso8601StringDateType.DATE ); conversion.put( StandardBasicTypes.TIME, Iso8601StringDateType.TIME ); conversion.put( StandardBasicTypes.TIMESTAMP, Iso8601StringDateType.DATE_TIME ); conversion.put( StandardBasicTypes.BYTE, RedisJsonByteType.INSTANCE ); conversion.put( StandardBasicTypes.INTEGER, RedisHashType.INTEGER ); conversion.put( StandardBasicTypes.SHORT, RedisHashType.SHORT ); conversion.put( StandardBasicTypes.LONG, RedisHashType.LONG ); conversion.put( StandardBasicTypes.DOUBLE, RedisHashType.DOUBLE ); conversion.put( StandardBasicTypes.FLOAT, RedisHashType.FLOAT ); conversion.put( StandardBasicTypes.BYTE, RedisHashType.BYTE ); conversion.put( BinaryType.INSTANCE, RedisJsonBlobType.INSTANCE ); conversion.put( MaterializedBlobType.INSTANCE, RedisJsonBlobType.INSTANCE ); conversion.put( StandardBasicTypes.SERIALIZABLE, RedisJsonBlobType.INSTANCE ); conversion.put( StandardBasicTypes.BOOLEAN, RedisHashType.BOOLEAN ); conversion.put( StandardBasicTypes.NUMERIC_BOOLEAN, RedisHashType.NUMERIC_BOOLEAN ); conversion.put( StandardBasicTypes.UUID_BINARY, RedisHashType.UUID_BINARY ); return conversion; }
private static Map<Type, AbstractGenericBasicType<?>> createGridTypeConversionMap() { Map<Type, AbstractGenericBasicType<? extends Object>> conversion = new HashMap<Type, AbstractGenericBasicType<? extends Object>>(); conversion.put( StandardBasicTypes.CALENDAR, Iso8601StringCalendarType.DATE_TIME ); conversion.put( StandardBasicTypes.CALENDAR_DATE, Iso8601StringCalendarType.DATE ); conversion.put( StandardBasicTypes.DATE, Iso8601StringDateType.DATE ); conversion.put( StandardBasicTypes.TIME, Iso8601StringDateType.TIME ); conversion.put( StandardBasicTypes.TIMESTAMP, Iso8601StringDateType.DATE_TIME ); conversion.put( StandardBasicTypes.BYTE, RedisJsonByteType.INSTANCE ); conversion.put( StandardBasicTypes.LONG, RedisJsonLongType.INSTANCE ); conversion.put( BinaryType.INSTANCE, RedisJsonBlobType.INSTANCE ); conversion.put( MaterializedBlobType.INSTANCE, RedisJsonBlobType.INSTANCE ); return conversion; }
@Override public Object nullSafeGet(final ResultSet resultSet, final String[] strings, final SessionImplementor sessionImplementor, final Object o) throws HibernateException, SQLException { try { byte[] value = BinaryType.INSTANCE.nullSafeGet(resultSet, strings[0], sessionImplementor); return decompress(value); } catch (Exception ex) { log.error("column=[" + strings[0] + "] 정보를 읽어 압축 복원하는데 실패했습니다.", ex); throw new HibernateException("압축된 정보를 복원하는데 실패했습니다.", ex); } }
@Override public void nullSafeSet(final PreparedStatement preparedStatement, final Object o, final int i, final SessionImplementor sessionImplementor) throws HibernateException, SQLException { try { byte[] value = compress((String) o); BinaryType.INSTANCE.nullSafeSet(preparedStatement, value, i, sessionImplementor); } catch (Exception ex) { log.error("Statement=[" + preparedStatement + "], index=[" + i + "]에 해당하는 값을 압축하는데 실패했습니다.", ex); throw new HibernateException("압축된 정보를 복원하는데 실패했습니다.", ex); } }
@Override public Object nullSafeGet(final ResultSet resultSet, final String[] strings, final SessionImplementor sessionImplementor, final Object o) throws HibernateException, SQLException { try { byte[] value = BinaryType.INSTANCE.nullSafeGet(resultSet, strings[0], sessionImplementor); return decompress(value); } catch (Exception ex) { log.error("column=" + strings[0] + " 정보를 읽어 압축 복원하는데 실패했습니다.", ex); throw new HibernateException("압축된 정보를 복원하는데 실패했습니다.", ex); } }
@Override public void nullSafeSet(final PreparedStatement preparedStatement, final Object o, final int i, final SessionImplementor sessionImplementor) throws HibernateException, SQLException { try { byte[] value = ArrayTool.isEmpty((byte[]) o) ? null : compress((byte[]) o); BinaryType.INSTANCE.nullSafeSet(preparedStatement, value, i, sessionImplementor); } catch (Exception ex) { log.error("Statement=[{}], index=[{}]에 해당하는 값을 압축하는데 실패했습니다.", preparedStatement, i); throw new HibernateException("정보를 압축하는데 실패했습니다.", ex); } }
boolean hasBlob() { for (String property: iMeta.getPropertyNames()) { if (iMeta.getPropertyType(property) instanceof BinaryType) return true; } return false; }
@Override public int[] sqlTypes() { return new int[]{ BinaryType.INSTANCE.sqlType() }; }
@Override public boolean isMutable() { return BinaryType.INSTANCE.isMutable(); }