SHARE
TWEET

Untitled

a guest Nov 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Iterator;
  2. import java.util.List;
  3.  
  4. import org.hibernate.Session;
  5. import org.hibernate.SessionFactory;
  6. import org.hibernate.query.Query;
  7.  
  8. import singleton.HibernateUtil;
  9.  
  10. public class prueba6 {
  11.  
  12.     public static void main(String[] args) {
  13.         SessionFactory sesion = HibernateUtil.getSessionFactory();
  14.         Session session = sesion.openSession();
  15.         Query<Empleados> q = session.createQuery("from Empleados WHERE departamentos=20");
  16.         List<Empleados> lista = q.list();
  17.         Iterator<Empleados> iterList = lista.iterator();
  18.         while (iterList.hasNext()) {
  19.             Empleados emple = (Empleados) iterList.next();
  20.             Departamentos depar=emple.getDepartamentos();
  21.             System.out.println("Numero: " + depar.getDeptNo() + " Apellido: " + emple.getApellido()+" Salario: "+emple.getSalario());
  22.         }
  23.     }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top