create transaction on shared EntityManager"/>
Not allowed to create transaction on shared EntityManager
您不能像这样启动事务。
您应该像这样使用声明性事务:
@Service
@Persistent
public class ProjectService {@PersistenceContextprivate EntityManager em;private Session session;@Transactionalpublic void insertEmployee throws Exception{em.createNativeQuery("insert into Employee (name,surname,) values('Phil','Bob'").executeUpdate(); }
}
请在 Spring 文档中阅读有关事务的更多信息:Data Access
更多推荐
Not allowed to create transaction on shared EntityManager
发布评论