Skip to content

Instantly share code, notes, and snippets.

@yusufcakmak
Created August 4, 2015 13:28
Show Gist options
  • Select an option

  • Save yusufcakmak/9e99791ab9e56e61ac6a to your computer and use it in GitHub Desktop.

Select an option

Save yusufcakmak/9e99791ab9e56e61ac6a to your computer and use it in GitHub Desktop.
public void getBook() {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
ArrayList<Book> bookList = (ArrayList<Book>) session.createQuery("from Book").list();
if(bookList !=null){
for (int i = 0; i < bookList.size(); i++) {
System.out.println("Book Name : " + bookList.get(i).getBookName());
System.out.println("Book Desc : " + bookList.get(i).getBookDesc());
}
}
session.getTransaction().commit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment