title: Spring Data JPA save() return entity
body: <p>I am using spring boot data jpa as below</p>
  
  <pre><code> @Entity
    @Table(name = "invoice")
    @Getter
    @Setter
    @ToString
    public class Invoice {
  
  
     @Id
      @Column(name = "inv_id")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private BigInteger invId;
  
      @Column(name = "external_id")
      private String externalInvoiceId;
  
      @Column(name = "amount")
      private double amount;
  
      @JsonIgnore
      @JsonIgnoreProperties
      @Column(name = "status")
      private int status;
  
      @JsonProperty("status")
      @Transient
      private String invoiceStatus;
  
  
      public String getInvoiceStatus() {
          switch (this.status){
              case 1:
                  return "INITIATED";
              case 2:
                  return "CANCELLED";
              case 3:
                  return "SUCCESS";
              case 4:
                  return "FAILURE";
              default:
                  return "IN PROGRESS";
  
          }
  
      }
  
      @CreationTimestamp
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "created_at")
      private Date createdAt;
  
      @UpdateTimestamp
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "updated_at")
      private Date updatedAt;
  
  
      @PostPersist
      public void updateExternalID() {
          this.externalInvoiceId="G".concat(String.valueOf(this.invId.multiply(BigInteger.valueOf(1000))))
                                    .concat(String.valueOf(Instant.now().getEpochSecond()));
  
      }
  }
  </code></pre>
  
  <p>Am accesing this entiry via repository as below</p>
  
  <pre><code>public interface InvoicesRepository extends JpaRepository&lt;Invoice, BigInteger&gt; {
  }
  </code></pre>
  
  <p>At my <code>@Service</code> am performing the below operation</p>
  
  <pre><code>@Autowired
      private InvoicesRepository myInvoicesRepository;
  
      Invoice transactionInvoice = new Invoice();
      transactionInvoice.setAmount(200.0);
      transactionInvoice.setStatus(1);
      Invoice savedInvoice = myInvoicesRepository.save(transactionInvoice);
  </code></pre>
  
  <p>Am using <code>savedInvoice</code> and trying to update the status. Either it is not updating the status properly nor I could not find the record in database too.</p>
  
  <p>There are no rollback present</p>
  
  <p>Below are the logs I could see insert statements are present</p>
  
  <pre><code>[XNIO-1 task-1] DEBUG org.hibernate.SQL.logStatement -
      /* insert com.min.app.model.Invoice
          */ insert
          into
              invoice
              (amount, created_at, external_inv_id, status, updated_at)
          values
              (?, ?, ?, ?, ?)
  Hibernate:
      /* insert com.min.app.model.Invoice
          */  insert
          into
              invoice
              (amount, created_at, external_inv_id, status, updated_at)
          values
              (?, ?, ?, ?, ?)
  </code></pre>
  
  <p>After the status updates I tried printing the <code>savedInvoice</code> could see the below in logs</p>
  
  <pre><code>Invoice(invId=58, externalInvoiceId=G580001575271905, amount=185.0 status=4, invoiceStatus=FAILURE, createdAt=Mon Dec 02 13:01:45 IST 2019, updatedAt=Mon Dec 02 13:01:45 IST 2019)
  </code></pre>
  
  <p>The above record I could not see in the table.</p>
  
  <p>What am I doing wrong?</p>