Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package br.ufmt.DadosAmbientais; /** * * @author igor */ import br.ufmt.dao.entity.User; import java.util.List; import junit.framework.TestCase; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class AppTest extends TestCase { public static void main(String[] args) { SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Session session = sessionFactory.openSession(); session.beginTransaction(); //AppUser user = new AppUser("admin"); //session.save(user); //session.getTransaction().commit(); // session.beginTransaction(); @SuppressWarnings("unchecked") List<User> todosUser = session.createQuery("select name from user_role").list(); System.out.println(todosUser); session.close(); //teste } }