📜  spring boot hibernate entitymanager - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:49.295000             🧑  作者: Mango

代码示例1
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("persistence");
        EntityManager entityManager = entityManagerFactory.createEntityManager();
 
        entityManager.getTransaction().begin();
        Employee employee = new Employee();
        employee.setName("Sanjay");
 
                // Save Entity
        entityManager.persist(employee);
        entityManager.getTransaction().commit();
        System.out.println("Generated Employee ID = " + employee.getEmployeeId());