vincentlaw
发贴: 7
积分: 2
|
于 2005-04-25 17:08
//GetData.java import org.hibernate.*; import org.hibernate.cfg.*; import java.io.*; import java.util.*;
public class GetData {
public static void main(String[] args) { try { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session session = sf.openSession(); Transaction tx = session.beginTransaction();
String hql="from User as user where 1=1"; Query query=session.createQuery(hql);
List userList=query.list(); System.out.println("List's length is:"+userList.size()); while (userList.next()) { //怎么输出userList的内容。谢谢。 } tx.commit(); session.close(); } catch (HibernateException e) { e.printStackTrace(); } } }
|