Guest User

Untitled

a guest
Oct 16th, 2011
159
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.slyvr;
  2.  
  3. import java.util.Iterator;
  4.  
  5. import org.hibernate.Query;
  6. import org.hibernate.Session;
  7. import org.hibernate.SessionFactory;
  8. import org.hibernate.cfg.Configuration;
  9.  
  10. import com.slyvr.pojo.Person;
  11.  
  12. import junit.framework.TestCase;
  13.  
  14.  
  15. public class DBConnectTest extends TestCase {
  16.  
  17.     SessionFactory sessionFactory;
  18.    
  19.     protected void setUp() {
  20.         // A SessionFactory is set up once for an application
  21.         sessionFactory = new Configuration().configure().buildSessionFactory();
  22.     }
  23.    
  24.     public void test() throws Exception{
  25.         Session session = sessionFactory.openSession();
  26.         Query query = session.createQuery("from Person");
  27.         Iterator it = query.iterate();
  28.         while(it.hasNext()){
  29.             Person row = (Person)it.next();
  30.             System.out.println(row.getUserName()+" "+row.getPassword());
  31.         }
  32.         session.close();
  33.     }
  34. }
  35.  
  36.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×