Skip to content

Instantly share code, notes, and snippets.

@craigew
Created September 28, 2013 13:44
Show Gist options
  • Save craigew/6742218 to your computer and use it in GitHub Desktop.
Save craigew/6742218 to your computer and use it in GitHub Desktop.
Method to allow for query on DataAccess
protected List<T> queryString(String sql){
EntityManagerFactory factory = Persistence.createEntityManagerFactory("JPAIntroduction");
EntityManager em = factory.createEntityManager();
List<T> results= em.createQuery(sql).getResultList();
em.close();
factory.close();
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment