Error: Found: decimal, expected: numeric

本文详细介绍了在使用Hibernate框架时,遇到decimal类型字段配置错误的解决方法,通过调整columnDefinition属性为decimal并设置精确度和小数位数,成功解决了报错问题。
java链接sqlserver 字段类型decimal(18, 2), 配置Hibernate映射文件时报错 Found: decimal, expected: numeric

@Column(name ="AVGRISK",nullable=true,precision=18,scale=2)
public BigDecimal getAvgrisk(){
return this.avgrisk;
}


修改如下:

@Column(name ="AVGRISK",nullable=true,columnDefinition="decimal",precision=18,scale=2)
public BigDecimal getAvgrisk(){
return this.avgrisk;
}
你解释一下这个函数呢 int config_plugin_values_init_block(server * const srv, const array * const ca, const config_plugin_keys_t * const cpk, const char * const mname, config_plugin_value_t *cpv) { /*(cpv must be list with sufficient elements to store all matches + 1)*/ int rc = 1; /* default is success */ for (int i = 0; cpk[i].ktype != T_CONFIG_UNSET; ++i) { const data_unset * const du = array_get_element_klen(ca, cpk[i].k, cpk[i].klen); if (NULL == du) continue; /* not found */ cpv->k_id = i; cpv->vtype = cpk[i].ktype; switch (cpk[i].ktype) { case T_CONFIG_ARRAY: case T_CONFIG_ARRAY_KVANY: case T_CONFIG_ARRAY_KVARRAY: case T_CONFIG_ARRAY_KVSTRING: case T_CONFIG_ARRAY_VLIST: if (du->type == TYPE_ARRAY) { cpv->v.a = &((const data_array *)du)->value; } else { log_error(srv->errh, __FILE__, __LINE__, "%s should have been a list like " "%s = ( \"...\" )", cpk[i].k, cpk[i].k); rc = 0; continue; } switch (cpk[i].ktype) { case T_CONFIG_ARRAY_KVANY: if (!array_is_kvany(cpv->v.a)) { log_error(srv->errh, __FILE__, __LINE__, "%s should have been a list of key => values like " "%s = ( \"...\" => \"...\", \"...\" => \"...\" )", cpk[i].k, cpk[i].k); rc = 0; continue; } break; case T_CONFIG_ARRAY_KVARRAY: if (!array_is_kvarray(cpv->v.a)) { log_error(srv->errh, __FILE__, __LINE__, "%s should have been a list of key => list like " "%s = ( \"...\" => ( \"...\" => \"...\" ) )", cpk[i].k, cpk[i].k); rc = 0; continue; } break; case T_CONFIG_ARRAY_KVSTRING: if (!array_is_kvstring(cpv->v.a)) { log_error(srv->errh, __FILE__, __LINE__, "%s should have been a list of key => string values like " "%s = ( \"...\" => \"...\", \"...\" => \"...\" )", cpk[i].k, cpk[i].k); rc = 0; continue; } break; case T_CONFIG_ARRAY_VLIST: if (!array_is_vlist(cpv->v.a)) { log_error(srv->errh, __FILE__, __LINE__, "%s should have been a list of string values like " "%s = ( \"...\", \"...\" )", cpk[i].k, cpk[i].k); rc = 0; continue; } break; /*case T_CONFIG_ARRAY:*/ default: break; } break; case T_CONFIG_STRING: if (du->type == TYPE_STRING) { cpv->v.b = &((const data_string *)du)->value; } else { log_error(srv->errh, __FILE__, __LINE__, "%s should have been a string like ... = \"...\"", cpk[i].k); rc = 0; continue; } break; case T_CONFIG_SHORT: switch(du->type) { case TYPE_INTEGER: cpv->v.shrt = (unsigned short)((const data_integer *)du)->value; break; case TYPE_STRING: { /* If the value came from an environment variable, then it is * a data_string, although it may contain a number in ASCII * decimal format. We try to interpret the string as a decimal * short before giving up, in order to support setting numeric * values with environment variables (e.g. port number). */ const char * const v = ((const data_string *)du)->value.ptr; if (v && *v) { char *e; long l = strtol(v, &e, 10); if (e != v && !*e && l >= 0 && l <= 65535) { cpv->v.shrt = (unsigned short)l; break; } } log_error(srv->errh, __FILE__, __LINE__, "got a string but expected a short: %s %s", cpk[i].k, v); rc = 0; continue; } default: log_error(srv->errh, __FILE__, __LINE__, "unexpected type for key: %s %d expected a short integer, " "range 0 ... 65535", cpk[i].k, du->type); rc = 0; continue; } break; case T_CONFIG_INT: switch(du->type) { case TYPE_INTEGER: cpv->v.u = ((const data_integer *)du)->value; break; case TYPE_STRING: { const char * const v = ((const data_string *)du)->value.ptr; if (v && *v) { char *e; long l = strtol(v, &e, 10); if (e != v && !*e && l >= 0) { cpv->v.u = (unsigned int)l; break; } } log_error(srv->errh, __FILE__, __LINE__, "got a string but expected an integer: %s %s",cpk[i].k,v); rc = 0; continue; } default: log_error(srv->errh, __FILE__, __LINE__, "unexpected type for key: %s %d expected an integer, " "range 0 ... 4294967295", cpk[i].k, du->type); rc = 0; continue; } break; case T_CONFIG_BOOL: { int v = config_plugin_value_tobool(du, -1); if (-1 == v) { log_error(srv->errh, __FILE__, __LINE__, "ERROR: unexpected type for key: %s (string) " "\"(enable|disable)\"", cpk[i].k); rc = 0; continue; } cpv->v.u = v; } break; case T_CONFIG_LOCAL: case T_CONFIG_UNSET: continue; case T_CONFIG_UNSUPPORTED: log_error(srv->errh, __FILE__, __LINE__, "ERROR: found unsupported key: %s (%s)", cpk[i].k, mname); srv->srvconf.config_unsupported = 1; continue; case T_CONFIG_DEPRECATED: log_error(srv->errh, __FILE__, __LINE__, "ERROR: found deprecated key: %s (%s)", cpk[i].k, mname); srv->srvconf.config_deprecated = 1; continue; } ++cpv; } cpv->k_id = -1; /* indicate list end */ return rc; }
最新发布
09-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值