Unable to insert newly added column data into mySql from Spring Data Jpa, Spring Data REST, liquibase and Angularjs based project

I am working on a Spring Data Jpa, Spring Data Rest, liquibase and AngularJs based project and is working fine for the existing columns of the Invoice Table. I added a new column 'ediNumber' to this table through liquibase which has successfully added new column to my Invoice Table (mySql). But the problem I am facing is when I am trying to insert new record from front end (Angularjs) the newly added column value is always getting inserted as null. I can clearly in the console before save function the object has ediNumber too.  

Save function in controller :

  $scope.save = function() {
     if ($scope.invoice.id != null) {
         Invoice.update($scope.invoice, onSaveFinished);
     } else {
         console.log(JSON.stringify($scope.invoice))
         Invoice.save($scope.invoice, onSaveFinished);
     }
 };

Open in new window


The above console log shows, the following where we can notice the ediNumber too. But ediNumber value is not getting inserted in the mySql database table.
{"accountNumber":"ACN8436346","invoiceNumber":"INV232643276","invoiceAmount":73466,"status":"Open","ediNumber":"EDI46464386","id":null}

Open in new window


In my browser console, the post request is getting formed as follows:

POST http://localhost:8080/api/invoices?cacheBuster=1444273583860 201 Created 158ms

{"id":8,"accountNumber":"ACN8436346","invoiceNumber":"INV232643276","invoiceAmount":73466.0,"status"
:"Open","invoiceDetailss":[]} 

Open in new window


Here you can notice there is no ediNumber, I am not able to understand why that ediNumber is not appearing in my post request. I made the following changes too in my back end,


In Invoice.java

 
/**
 * A Invoice.
 */
@Entity
@Table(name = "invoice")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Invoice implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    
    @Column(name = "account_number")
    private String accountNumber;
    
    @Column(name = "invoice_number")
    private String invoiceNumber;
    
    @Column(name = "invoice_amount")
    private Double invoiceAmount;
    
    @Column(name = "status")
    private String status;
    
    @Column(name = "edi_number")
    private String ediNumber;

    
	@OneToMany(mappedBy = "invoice")
    //@JsonIgnore
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    private Set<InvoiceDetails> invoiceDetailss = new HashSet<>();

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getInvoiceNumber() {
        return invoiceNumber;
    }

    public void setInvoiceNumber(String invoiceNumber) {
        this.invoiceNumber = invoiceNumber;
    }

    public Double getInvoiceAmount() {
        return invoiceAmount;
    }

    public void setInvoiceAmount(Double invoiceAmount) {
        this.invoiceAmount = invoiceAmount;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
    
    public String getEdiNumber() {
		return ediNumber;
	}

	public void setEdiNumber(String ediNumber) {
		this.ediNumber = ediNumber;
	}


    public Set<InvoiceDetails> getInvoiceDetailss() {
        return invoiceDetailss;
    }

    public void setInvoiceDetailss(Set<InvoiceDetails> invoiceDetailss) {
        this.invoiceDetailss = invoiceDetailss;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Invoice invoice = (Invoice) o;

        if ( ! Objects.equals(id, invoice.id)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "Invoice{" +
                "id=" + id +
                ", accountNumber='" + accountNumber + "'" +
                ", invoiceNumber='" + invoiceNumber + "'" +
                ", invoiceAmount='" + invoiceAmount + "'" +
                ", ediNumber='" + ediNumber + "'" +
                ", status='" + status + "'" +
                '}';
    }
}

Open in new window


in InvoiceResource.java, I have post call as,

 /**
     * POST  /invoices -> Create a new invoice.
     */
    @RequestMapping(value = "/invoices",
            method = RequestMethod.POST,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @Timed
    public ResponseEntity<Invoice> create(@RequestBody Invoice invoice) throws URISyntaxException {
        log.debug("REST request to save Invoice : {}", invoice);
        if (invoice.getId() != null) {
            return ResponseEntity.badRequest().header("Failure", "A new invoice cannot already have an ID").body(null);
        }
        Invoice result = invoiceRepository.save(invoice);
        return ResponseEntity.created(new URI("/api/invoices/" + result.getId()))
                .headers(HeaderUtil.createEntityCreationAlert("invoice", result.getId().toString()))
                .body(result);
    }

Open in new window



And the following is my backend debug log on spring data jpa end,
[DEBUG] com.sample.web.rest.InvoiceResource - REST request to save Invoice : Invoice{id=null, accountNumber='ACN8436346', invoiceNumber='INV232643276', invoiceAmount='73466.0', status='Open'}
Hibernate: insert into invoice (account_number, invoice_amount, invoice_number, status) values (?, ?, ?, ?)
[DEBUG] com.sample.aop.logging.LoggingAspect - Exit: com.sample.web.rest.InvoiceResource.create() with result = <201 Created,Invoice{id=8, accountNumber='ACN8436346', invoiceNumber='INV232643276', invoiceAmount='73466.0', status='Open'},{Location=[/api/invoices/8], X-sampleApp-alert=[sampleApp.invoice.created], X-sampleApp-params=[8]}>  

Open in new window

Too SmartAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gurpsbassiCommented:
Have you recompiled your server side code?
The debug message doesn't seem to reflect the toString() method in Invoice.java

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Too SmartAuthor Commented:
Ok, I will recompile the code again and then update by 8pm.
Too SmartAuthor Commented:
That is the catch. My code did not compiled properly. I restarted eclipse and then compiled again then every thing went well. Thanks for catching it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.