首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

hibernate类找不到的有关问题

2011-12-26 
hibernate类找不到的问题import org.hibernate.HibernateExceptionimport org.hibernate.Queryimport or

hibernate类找不到的问题
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public Blog getBlog(String userId) throws HibernateException {
  Session session = HibernateUtil.currentSession();
  Blog blog = null;
Transaction tx = null;
try {
tx = session.beginTransaction();

Query query = session.createQuery("from Blog where username=:userId");
query.setParameter("userId", userId);
List list = query.list();
if (!list.isEmpty())
blog = (Blog) list.get(0);
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw e;
}
session.close();
return blog;
}
}

提示
“找不到符号 符号:类HibernateException ”
“找不到符号 符号:类Session”
“找不到符号 符号:类Transaction ”

lib文件夹下已经添加了hibernate3.jar

[解决办法]
lib文件夹下已经添加了hibernate3.jar

这个有啥用?这个不是在编译的时候使用的。你应该把它加入你的CLASSPATH

如果你用 Eclipse 你应该加入 Build_path
[解决办法]
要在eclipse里面把hibernate3.jar包含进来的
[解决办法]
如果你是部署运行,需要在 CLASSPATH里面加上hibernate3.jar ,如果是在IDE中运行,则需要导入
[解决办法]
lib包里面加了,不一定在里的classpath里了呀.
[解决办法]
应该是对应的jar包没有找到,重新导入试试,要是不行,就重新找个可以用的jar包

热点排行