title: How do I get the primary Key after entity.merge
body: <p>I am using entity.merge from my SpringBoot JPA Hibernate to persist certain data in Oracle database where primary key is Sequence generated.
  But after merge , I am not able to get the primary key which is inserted into the Oracle table. For both the cases it is returning 0</p>
  
  <pre><code>LOG.info("Inside InsertParts&gt;&gt;&gt;&gt;Before Merge Component-serialized_id&gt;&gt;&gt;&gt;" +webCrtPart.getSerializedComponentId()+ "&gt;&gt;&gt;CSI&gt;&gt;" +webCrtPart.getCsInvSerialNumber());
      // Persist entity to database
      mergeEntity(webCrtPart);
  
      i++;
      // checking the batchsize so after every batch of batchsize , it
      // gets inserted to database
      if (i % batchSize == 0) {
          // Flush a batch of inserts and release memory.
          entityManager.flush();
          entityManager.clear();
      }
  
      LOG.info("Inside InsertParts&gt;&gt;&gt;&gt;After merge Component-serialized_id&gt;&gt;&gt;&gt;"+webCrtPart.getSerializedComponentId());
  }
  
  return webCrtPartList;
  </code></pre>
  
  <p>}</p>
  
  <hr>
  
  <p>And my Entity Class looks like :</p>
  
  <pre><code>@Table(name = "WEBCRT_CMPNT_SRLZD")
  @Entity
  public class WebCrtSerializedComponent {
  
      @Id 
      @SequenceGenerator(name="component_seq", sequenceName="WEBCRT_CMPNT_SRLZD_SEQ"  , allocationSize=1)
      @GeneratedValue(generator = "component_seq", strategy = GenerationType.SEQUENCE)
      @Column(name = "CMPNT_SRLZD_SEQ_ID")
      private Long serializedComponentId;
  
      @Column(name = "ITM")
      private String item;
  
      @Column(name = "SUB_CMPNT_SEQ_ID")
      private String subComponentSeqId;
  
      @Column(name = "PRT_NUM")
      private String partNumber;
  
      @Column(name = "INCMNG_SRL_NUM")
      private String incomingSerialNumber;
  
      @Column(name = "NUM_OF_PREV_RPRS")
      private String previousRepairCount;
  </code></pre>
  
  <hr>
  
  <p>Please find the following log:</p>
  
  <pre><code>2016-09-28 15:42:19.861[0;39m [32m INFO[0;39m [35m63710[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet       [0;39m [2m:[0;39m FrameworkServlet 'dispatcherServlet': initialization completed in 25 ms
  [2m2016-09-28 15:42:19.934[0;39m [32m INFO[0;39m [35m63710[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mc.g.p.b.m.impl.JobRetrievalManager      [0;39m [2m:[0;39m parameters to be passed : - 159693-----10
  [2m2016-09-28 15:42:20.484[0;39m [32m INFO[0;39m [35m63710[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mc.g.p.b.managers.impl.PartSynchManager  [0;39m [2m:[0;39m JobControllerV1 &gt;&gt;&gt;&gt;&gt;&gt;&gt;1
  [2m2016-09-28 15:42:20.491[0;39m [32m INFO[0;39m [35m63710[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mc.g.p.b.r.PartSynchRepositoryImpl       [0;39m [2m:[0;39m Inside InsertParts&gt;&gt;&gt;&gt;Before Merge Component-serialized_id&gt;&gt;&gt;&gt;0&gt;&gt;&gt;CSI&gt;&gt;null
  Hibernate: select webcrtseri0_.cmpnt_srlzd_seq_id as cmpnt_srlzd_seq_id1_3_0_, webcrtseri0_.child_sys_asmbly_id as child_sys_asmbly_i2_3_0_, webcrtseri0_.crtd_by as crtd_by3_3_0_, webcrtseri0_.crtn_dt as crtn_dt4_3_0_, webcrtseri0_.csinv_sl_num as csinv_sl_num5_3_0_, webcrtseri0_.cust_supplied_ind as cust_supplied_ind6_3_0_, webcrtseri0_.incmng_dpm_ind as incmng_dpm_ind7_3_0_, webcrtseri0_.incmng_srl_num as incmng_srl_num8_3_0_, webcrtseri0_.itm as itm9_3_0_, webcrtseri0_.job_seq_id as job_seq_id10_3_0_, webcrtseri0_.lst_updtd_by as lst_updtd_by11_3_0_, webcrtseri0_.lst_updt_dt as lst_updt_dt12_3_0_, webcrtseri0_.outgng_dpm_ind as outgng_dpm_ind13_3_0_, webcrtseri0_.otgng_pn as otgng_pn14_3_0_, webcrtseri0_.otgng_sn as otgng_sn15_3_0_, webcrtseri0_.prt_num as prt_num16_3_0_, webcrtseri0_.prev_job_num as prev_job_num17_3_0_, webcrtseri0_.num_of_prev_rprs as num_of_prev_rprs18_3_0_, webcrtseri0_.repl_ind as repl_ind19_3_0_, webcrtseri0_.sub_cmpnt_seq_id as sub_cmpnt_seq_id20_3_0_, webcrtseri0_.set_sys_asmbly_id as set_sys_asmbly_id21_3_0_ from webcrt_cmpnt_srlzd webcrtseri0_ where webcrtseri0_.cmpnt_srlzd_seq_id=?
  Hibernate: select WEBCRT_CMPNT_SRLZD_SEQ.nextval from dual
  [2m2016-09-28 15:42:20.628[0;39m [32m INFO[0;39m [35m63710[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mc.g.p.b.r.PartSynchRepositoryImpl       [0;39m [2m:[0;39m Inside InsertParts&gt;&gt;&gt;&gt;After merge Component-serialized_id&gt;&gt;&gt;&gt;0
  Hibernate: insert into webcrt_cmpnt_srlzd (child_sys_asmbly_id, crtd_by, crtn_dt, csinv_sl_num, cust_supplied_ind, incmng_dpm_ind, incmng_srl_num, itm, job_seq_id, lst_updtd_by, lst_updt_dt, outgng_dpm_ind, otgng_pn, otgng_sn, prt_num, prev_job_num, num_of_prev_rprs, repl_ind, sub_cmpnt_seq_id, set_sys_asmbly_id, cmpnt_srlzd_seq_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
  </code></pre>