我正在尝试将List
Hibernate 返回的转换为UserDetails[]
数组,如下所示:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
List<UserDetails[]> oo = session.createSQLQuery("SELECT * FROM `userdetails` WHERE 1 ").list();
System.out.println(oo.size()); // Until here it works fine and it shows me the rows I asked in my query.
UserDetails[]us = oo.toArray(new UserDetails[oo.size()]); // Here it throws java.lang.ArrayStoreException
session.close();
但是,它会抛出一个java.lang.ArrayStoreException
. 这是如何引起的,我该如何解决?