Fare query scrittura e lettura con PersistenceManager
PersistenceManager.initialize();
try {
EntityManager entityManager = PersistenceManager.getEntityManagerFactory().createEntityManager();
entityManager.getTransaction().begin();
User user = new User();
user.setUsername("mariorossi01");
entityManager.persist(user);
List<User> users = entityManager.createQuery("SELECT u FROM User u", User.class).getResultList();
for (User u : users) {
System.out.println("User: " + u.getId() + ", " + u.getUsername());
}
entityManager.getTransaction().commit();
}catch(Exception e){
return;
}
PersistenceManager.close();