场景: mysql数据库定义数据类型为bigInt, hibernate映射文件中定义类型为Long,通过hibernate查询出来的确实java.math.BigInteger
[code="java"]
private Long id;
private Long projectId;
private Long orgRoleId;
[/code]
[code="java"]
[/code]
数据库定义类型为bigInt, Mysql数据库
查询:
[code="java"]
List> list = this.hibernateTemplate
.execute(new HibernateCallback>>() {
public List<Map<String, Object>> doInHibernate(
Session session) throws HibernateException,
SQLException {
List find = null;
String sql = "select t1.* ,t2.portalItemId as itemId ,t2._column ,t2._row ,t2._order ,t2.orgRoleId ,t2.projectId, t2.workZoneSiteId ,t2.portalItemHeight,t2.portalItemWidth from portal_item as t1,portal_default_workzonesite_item as t2 where t1.status=1 and t1.id=t2.portalItemId and t2.workZoneSiteId='"
+ workZoneSiteId + "'";
SQLQuery query = session.createSQLQuery(sql);
query
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
find = query.list();
return find;
}
});
[/code]
在得到的list拿出相应原本以为Long类型数据进行Long型转换时抛出Exception:
ClassCastException: cannot cast java.math.BigInteger to java.lang.Long
请问有人遇到过这情况吗,请问发生这种不预期的异常原因在哪?谢谢