Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » DescriptorEventAdapter and Invoice Header/Line
DescriptorEventAdapter and Invoice Header/Line [message #1410519] Thu, 21 August 2014 01:22 Go to next message
Omar Carvajal is currently offline Omar CarvajalFriend
Messages: 6
Registered: September 2010
Junior Member
Hey all,

I have a case that's similar to the age old invoice header/line model.

Whenever an invoice line is added, updated or deleted, the header total must be updated.

I am trying to implement a DescriptorEventAdapter listener for this case, I just can't seem to get the invoice header to update.

No matter what I do, the SQL for the invoice header update is never generated.

This is what I am trying:

	public void preInsert(DescriptorEvent event) {
		InvoiceLine invoiceLine = (InvoiceLine) event.getObject();
		... CALCULATE TOTAL HERE ...

		InvoiceHeader invoiceHeader = invoiceLine.getHeader();
		invoiceHeader.setTotal(total);
		event.getSession().updateObject(invoiceHeader);
	}


When I check the database, the invoice header's total is never updated.

I've also tried using postInsert and aboutToInsert instead of preInsert.

Any pointers as to what I am doing wrong?

Thanks in advance,

Omar
Re: DescriptorEventAdapter and Invoice Header/Line [message #1410895 is a reply to message #1410519] Thu, 21 August 2014 22:35 Go to previous message
Omar Carvajal is currently offline Omar CarvajalFriend
Messages: 6
Registered: September 2010
Junior Member
From what I can gather, the UnitOfWork does detect the changes, however the SQL statements never gets sent to the database.

Do I need to just flush the transaction somehow?

Omar
Previous Topic:Error binding to externally managed transaction
Next Topic:NoSQL|Mongo : How to use ObjectID ?
Goto Forum:
  


Current Time: Sat Feb 28 00:54:09 GMT 2015

Powered by FUDForum. Page generated in 0.08003 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software