hibernate-entitymanager for java 15 code example
Example 1: spring boot hibernate entitymanager
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("persistence");
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
Employee employee = new Employee();
employee.setName("Sanjay");
entityManager.persist(employee);
entityManager.getTransaction().commit();
System.out.println("Generated Employee ID = " + employee.getEmployeeId());
Example 2: spring boot hibernate entitymanager
entityManager.close();
entityManagerFactory.close();