I encountered a small problem when I used JPA yesterday. entitymanager was injected through the @ persistcontext method. There is no problem in using entitymanager to query objects, but data cannot be saved to the database during persistence,ProgramNo exception is thrown. After a day, I always thought it was persistence. where is the XML file going wrong? Finally, I checked the information online and found the difference between JTA and resource_local in transaction-type. I thought that I did not add the @ transactional tag before calling the persis () method. Now the problem has been solved. I sincerely thank Baidu and Google for sharing their experience in solving the problem on the Internet!
Reprinted: The difference between JTA and resource_local is that one is declarative transaction management. The container takes care of the EJB method process that you added @ transactionattribut (XXXX) annotation, the other one needs to manually obtain a transaction handle from Em and use programming transaction management methods such as begin () and commit ().