String hql=" from DEPT where deptno='94' "; 有问题
DEPT是你的类名,不是表名
DEPT是你的类名,不是表名
解决方案 »
- Axis2+spring2.0+Tomcat5.5访问数据库的问题!!!
- struts2 拦截器问题
- jre、tomcat、apache有什么区别与联系
- 在Linux操作系统中如何使用Java解压缩rar的文件
- 请问:想要J2EE编程中有所成就,要学好哪几方面内容?
- WebService非要有Web服务器运行吗?
- struts问题,看过卫琴mm的书的近来看看!^(oo)^
- 真天真的高兴成为Java Java Enterprise Open Source版主散分
- 求助hibernate问题
- 在RMI-IIOP中怎么实现类似Corba中的Callback功能
- 怎么能让Firefox显示java Applet?需要什么插件?
- 请问在java中如何调用asp.net的webservice??
select Dname from DEPT where deptno='94';
这句在cmd里都可以正确执行,而且我就是用的scott下那四个表
Hibernate: select from where (deptno='94' )根本没有选择对象,是不是还要set什么东西进去
Hibernate: select from where (deptno='94' )
应该是类中缺少set函数。
import net.sf.hibernate.Session;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Transaction;
import net.sf.hibernate.Query;
import java.util.Iterator;
import net.sf.hibernate.collection.List;
import net.sf.hibernate.collection.Set; public class Test{
public Test() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
} public static void main(String[] args) {try{
String hql=" from DEPT ";
Configuration config=new Configuration().configure();
SessionFactory sf =config.buildSessionFactory();
Session session =sf.openSession();
List list=(List)session.createQuery(hql);
Iterator it=list.iterator();
while (it.hasNext())
{
Dept dept=(Dept)it.next();
System.out.println(it.next());
}
} catch (HibernateException e) {
e.printStackTrace();
} } private void jbInit() throws Exception {
}
}错误如下:
Hit uncaught exception java.lang.ClassCastException
2 要保证你的Dept类里有setDeptno method.
了,
确有setDeptno method.错误如下
Hibernate: select from where (deptno='94' )