JAVA 强制类型转换错误提示
2016-02-20 14:18
459 查看
public float findPriceByIsbn(String isbn) {
String hql="select b.price from Book b where b.isbn=?";
float price=(float)getSession().createQuery(hql).setString(0, isbn).uniqueResult();
return price;
}
在做类型强势转换拿时将要强制转换的类型写成一般的数据类型报错Cannot cast from Object to float,
后来改为
public float findPriceByIsbn(String isbn) {
String hql="select b.price from Book b where b.isbn=?";
float price=(Float)getSession().createQuery(hql).setString(0, isbn).uniqueResult();
return price;
}
在做强制转换时,float——>Float, int——>Integer
记录错误。
String hql="select b.price from Book b where b.isbn=?";
float price=(float)getSession().createQuery(hql).setString(0, isbn).uniqueResult();
return price;
}
在做类型强势转换拿时将要强制转换的类型写成一般的数据类型报错Cannot cast from Object to float,
后来改为
public float findPriceByIsbn(String isbn) {
String hql="select b.price from Book b where b.isbn=?";
float price=(Float)getSession().createQuery(hql).setString(0, isbn).uniqueResult();
return price;
}
在做强制转换时,float——>Float, int——>Integer
记录错误。
相关文章推荐
- spring mvc 的两种配置方式继承controller和xml配置delegate
- 用JAVA写的插入排序
- String类型
- windows下,用eclipse连接虚拟机中的hadoop
- Java并发读取List2
- springMVC搭建
- JAVA集合类总结
- SpringMVC项目使用Thymeleaf模板引擎
- 浅析Java内存分配机制
- JAVA super() this() 详解
- Java学习笔记2016.2.20 访问修饰符、包
- Java測试覆盖率工具----Cobertura,EclEmma
- 命令行运行程序 解决 java “错误:编码GBK 的不可映射字符”
- Java多线程的通信2
- Spring+SpringMVC项目搭建
- JAVA多线程-线程间通信(一)-等待/通知机制(wait/notify)
- Java多线程的通信1
- MyEclipse安装后需要进行的配置
- MyEclipse安装后需要进行的配置
- Java初学之IO(二)