我想将列的名称放入 HQL 查询结果中(带有未知的查询内容和类“学生”属性)
> Query query = session.createQuery("from Student s ");
> ScrollableResults list = query.scroll(ScrollMode.FORWARD_ONLY);
>
> while (list.next()) {
>
> for(Object obj : list.get()){
> System.out.println(">>>>>>>>>>>>: "+ obj);
> }
>
> }
像这样
Statement stmt = conn.createStatement();
ResultSet resultSet = stmt.executeQuery("SELECT * FROM student");
ResultSetMetaData md = resultSet.getMetaData();
for (int i = 1; i <= md.getColumnCount(); i++)
System.out.print(md.getColumnLabel(i) + " ");