himg = himgDao.findUniqueBy("houseId", entity.getId());如上代码我的houseId为int型,我的entity.getId()为long行,这样我每次运行的时候都说类型错误,如何转换?如何写呢?
在线等,说对的分全送~
在线等,说对的分全送~
解决方案 »
- 连接oracle异常:org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io 异常: Got minus one
- Eclipse中hibernate连接informix数据库问题
- tomacat5.028+Eclipse3.2+structs+sqlserver2000 中文乱码
- jsp页面怎么访问外部类?
- 福娃免费空间
- 请教tomcat下如何将war文件配置成网站根目录运行?
- 狂晕,简单语句出错?
- 想学J2EE,请大家给推荐几本好书吧!有劳了!
- servlet如何与数据库相连?求救,急!!!
- 请问TagClass 和TeiClass的区别?
- tomcat怎么配置hibernate项目
- JDBC连接数据库 ResultSet.updataRow();是什么意思?
himg = himgDao.findUniqueBy(houseId, entity.getId());
2、entity.getId()进行强制转换成int,但是可能会产生精度丢失!
int i1 = 10; //定义一个int型变量
long l1 = 10L;//定义一个long型变量
int i2 = (int)l;//通过强制转换把一个long型的变量转换成一个int型变量
//int i2 = l;这样会出编译错误
long l2 = i1;//int型变量会自动转换
4楼的提示 cannot cast long to int!
------------------------------------
我都不知道你什么意思了?是把entity.getId()改为int型吗?
那就那样
himg = himgDao.findUniqueBy("houseId", new Interger(entity.getId()));
修正
himg = himgDao.findUniqueBy("houseId", new Integer(entity.getId()));
pre=(entity.getId()> > 16)&0xffff; //取高字节
suffix=entity.getId()&0xffff; //取低字节
himg = himgDao.findUniqueBy(new Long(houseId), entity.getId());