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
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
楼主【clifford9】截止到2008-06-28 16:12:09的历史汇总数据(不包括此帖):
发帖数:20 发帖分:510
结贴数:17 结贴分:450
未结数:3 未结分:60
结贴率:85.00 % 结分率:88.24 %
楼主加油