Le operazioni avvengono in questo modo dal portale
codice:
@Autowired private SessionFactory sessionFactory;
private Session getCurrentSession() {
return sessionFactory.getCurrentSession();
}
public void addContenuto(Contenuto contenuto) {
getCurrentSession().save(contenuto);
}
public void updateContenuto(Contenuto contenuto) {
getCurrentSession().update(contenuto);
}
e vengono recuperate dal webService in questo modo
codice:
public List<Contenuto> findContenutoByIdUtente(Integer idUtente) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("Contenuto.findByIdUtente");
query.setParameter("idUtente", idUtente);
return query.getResultList();
} finally {
em.close();
}
}