实体类
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator1")
@SequenceGenerator(sequenceName = "sequence2", name = "generator1",
allocationSize = 1, initialValue = 1)
private int id;
主要的
EntityManagerFactory emf = Persistence.createEntityManagerFactory("Employee");
entityManager = emf.createEntityManager();
Employee us = new Employee();
us.setFirstname("John");
us.setLastname("John");
entityManager.getTransaction().begin();
entityManager.persist(us);
entityManager.getTransaction().commit();
第一个 ID 号是 1,但是当我再次运行它时,它会创建一个 ID 号 3(应该是 2?),我不知道为什么。这里有什么问题?