@SuppressWarnings("unchecked")
public static List<NewsBean> creareListaNews() {
List<News> n = new ArrayList<News>();
List<NewsBean> data = new ArrayList<NewsBean>();
NewsBean c = new NewsBean();
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("modul3L2");
em = emf.createEntityManager();
em.getTransaction().begin();
Query query = em.createQuery("SELECT n FROM News n");
n = query.getResultList();
int i = 0;
for (News ind : n) {
c.setContinutNews(ind.getContinut());
c.setContinutShortNews(ind.getContinut().substring(0, 90) + "...");
data.add(c);
}
em.getTransaction().commit();
em.close();