I\'m using JPA (EclipseLink) and Spring. Say I have a simple entity with an auto-generated ID:
@Entity public class ABC implements Serializable { @Id
This is how I did it:
EntityManager entityManager = getEntityManager(); EntityTransaction transaction = entityManager.getTransaction(); transaction.begin(); entityManager.persist(object); transaction.commit(); long id = object.getId(); entityManager.close();