@Override
    public <X> Object wrap(X value, WrapperOptions options) {
        if (value == null) {
            return null;
        }

        Blob blob = null;
        Clob clob = null;

        if (Blob.class.isAssignableFrom(value.getClass())) {
            blob = options.getLobCreator().wrap((Blob) value);
        }  if (Clob.class.isAssignableFrom(value.getClass())) {
             clob = options.getLobCreator().wrap((Clob) value);
        } else if (byte[].class.isAssignableFrom(value.getClass())) {
            blob = options.getLobCreator().createBlob((byte[]) value);
        } else if (InputStream.class.isAssignableFrom(value.getClass())) {
            InputStream inputStream = (InputStream) value;
            try {
                blob = options.getLobCreator().createBlob(inputStream, inputStream.available());
            } catch (IOException e) {
                throw unknownWrap(value.getClass());
            }
        }

        String stringValue;
        try {
            if (blob != null) {
                stringValue = new String(DataHelper.extractBytes(blob.getBinaryStream()));
            } else if (clob != null) {
                stringValue = DataHelper.extractString(clob);
            } else {
                stringValue = value.toString();
            }
        } catch (SQLException e) {
            throw new HibernateException("Unable to extract binary stream from Blob", e);
        }

        return fromString(stringValue);
    }
@Test
    public void testNullPropertyType() {
        JsonTypeDescriptor descriptor = new JsonTypeDescriptor();

        try {
            descriptor.wrap("a", null);
            fail("Should fail because the propertyType is null!");
        } catch (HibernateException expected) {
        }
    }