hibernate中session.createQuery取记录列表,但得到的却是乱码(?号),怎么解决?
取记录过程:
public List getBugList()
{
Session session = null;
try
{
session = SessionFactory.currentSession();
Query query =
session.createQuery(
"select Buginfo from com.wins.hibernate.Buginfo Buginfo order by Buginfo.id desc");
return query.list();
}
catch (HibernateException e)
{
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}
}
想用下面这个方法转换,可不知道怎么用,老是说类型不匹配:
public static String GBK2ISO(String s)
throws Exception
{
return new String(s.getBytes("GBK"), "ISO8859_1");
}
不知道怎么解决,有没有其他的方法。我用的是MySQL数据库。