I have problem with using EntityManager.persist(Object)
method. Now when i get rid of other problems, by app work without Exception but object is not put in my data
You can open the new Transaction and then commit your records.
@PersistenceUnit(unitName = "NameOfPersistenceUnit")
private EntityManagerFactory entityManagerFactory;
void someMethod(AccountCommodity accountCommodity){
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
entityManager.persist(accountCommodity);
entityManager.flush();
entityManager.getTransaction().commit();
entityManager.close();
}