Hibernate使用255长度的Blob

时间:2017-12-19 09:28:30

标签: java hibernate

我有一个类,其中有一个用@Lob注释的属性。 Hibernate默认使用255作为长度 - 使用HSQLDB日志验证这一点。 hibernate不应该使用默认值,具体取决于数据库的类型吗?

@Converter
class LobCustomModelConverter implements AttributeConverter<CustomModel, byte[]> {

    ObjectMapper mapper = new ObjectMapper()

    @Override
    byte[] convertToDatabaseColumn(CustomModel model) {
        mapper.writeValueAsBytes(model)
    }

    @Override
    CustomModel convertToEntityAttribute(byte[] s) {
        mapper.readValue(s, CustomModel)
    }

}

转换器:

HttpClient httpclient;
HttpPost httppost;
ArrayList<NameValuePair> postParameters;
httpclient = new DefaultHttpClient();
httppost = new HttpPost("your login link");


postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("param1", "param1_value"));
postParameters.add(new BasicNameValuePair("param2", "param2_value"));

httpPost.setEntity(new UrlEncodedFormEntity(postParameters, "UTF-8"));

HttpResponse response = httpclient.execute(httpPost);

0 个答案:

没有答案