@@ -0,0 +1,2395 @@
+package com.vladmihalcea.book.hpjp.hibernate.flushing;%0A%0Aimport com.vladmihalcea.book.hpjp.util.AbstractTest;%0Aimport org.junit.Test;%0A%0Aimport javax.persistence.*;%0A%0A/**%0A * @author Vlad Mihalcea%0A */%0Apublic class IdentityOrderTest extends AbstractTest %7B%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new Class%3C?%3E%5B%5D %7B%0A            Post.class%0A        %7D;%0A    %7D%0A%0A    private Long postId;%0A%0A%0A    @Test%0A    public void tesOperationOrder() %7B%0A%0A        EntityManager entityManager = null;%0A        EntityTransaction txn = null;%0A        try %7B%0A            entityManager = entityManagerFactory().createEntityManager();%0A            Post post = new Post();%0A            post.setTitle(%22High-Performance Java Persistence%22);%0A            post.setSlug(%22high-performance-java-persistence%22);%0A%0A            entityManager.persist(post);%0A            entityManager.getTransaction().begin();%0A            entityManager.flush();%0A            entityManager.getTransaction().commit();%0A        %7D catch (Throwable e) %7B%0A            if ( txn != null && txn.isActive()) txn.rollback();%0A            throw e;%0A        %7D finally %7B%0A            if (entityManager != null) %7B%0A                entityManager.close();%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void tesOperationOrderWithManualFlush() %7B%0A        doInJPA(entityManager -%3E %7B%0A            Post post = entityManager.find(Post.class, postId);%0A            entityManager.remove(post);%0A            entityManager.flush();%0A%0A            Post newPost = new Post();%0A            newPost.setTitle(%22High-Performance Java Persistence Book%22);%0A            newPost.setSlug(%22high-performance-java-persistence%22);%0A            entityManager.persist(newPost);%0A        %7D);%0A    %7D%0A%0A    @Entity(name = %22Post%22)%0A    @Table(name = %22post%22)%0A    public static class Post %7B%0A%0A        @Id%0A        @GeneratedValue(strategy = GenerationType.IDENTITY)%0A        private Long id;%0A%0A        private String title;%0A%0A        private String slug;%0A%0A        public Long getId() %7B%0A            return id;%0A        %7D%0A%0A        public void setId(Long id) %7B%0A            this.id = id;%0A        %7D%0A%0A        public String getTitle() %7B%0A            return title;%0A        %7D%0A%0A        public void setTitle(String title) %7B%0A            this.title = title;%0A        %7D%0A%0A        public String getSlug() %7B%0A            return slug;%0A        %7D%0A%0A        public void setSlug(String slug) %7B%0A            this.slug = slug;%0A        %7D%0A    %7D%0A%7D%0A

Add IDENTITY order