このコードを持っている:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Query query = session.createQuery("from DBUser where id=1");
for(Iterator it=query.iterate();it.hasNext();){
Object[] row = (Object[]) it.next();
System.out.println("ID: " + row[0]);
System.out.println("Name: " + row[1]);
System.out.println("Amount: " + row[2]);
}
エラーが発生します:java.lang.ClassCastException: com.mycompany.app.DBUser cannot be cast to [Ljava.lang.Object;
おそらく、テーブルから単一の要素を取得するためのより簡単な方法がありますか?