Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.

Public Report
Report From: C#Builder/ECO/Core    [ Add a report in this area ]  
Report #:  29058   Status: Closed
OrderBy(<Role>.Attribute) doesn't work in OclPSHandle
Project:  C#Builder Build #:  10.02
Version:    10.0 Submitted By:   Jose Maria Sanmartin
Report Type:  Basic functionality failure Date Reported:  5/12/2006 8:53:46 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   240150
Resolution: Duplicate (Resolution Comments) Resolved in Build: : 11.0.2567.3471
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 2
Description
I have an Invoice class with an attribute called number: String. This class
has an 0.* Association with InvoiceLine class which has an attribute line:
Integer.

The Expression:

InvoiceLine.allInstances->orderBy(invoice.number)

in OclPSHandle doesn't show any object. With ExpressionHandle it shows all
the objects.

Is there any reason why I can not order by an attribute from a role?


The problem here is that the SQL generated is wrong in the JOIN between Invoice and Invoice line

It is generated:

SELECT InvoiceLin_1.ECO_ID
FROM InvoiceLine InvoiceLin_1
JOIN Invoice Invoice_1
ON (Invoice_1.ECO_ID = InvoiceLin_1.ECO_ID)  // Wrong
ORDER BY Invoice_1.number


And should be:

SELECT InvoiceLin_1.ECO_ID
FROM InvoiceLine InvoiceLin_1
JOIN Invoice Invoice_1
ON (Invoice_1.ECO_ID = InvoiceLin_1.invoice)   // OK
ORDER BY Invoice_1.number

I have attached an example

Steps to Reproduce:
1.- Create a new C#Builder Project
2.- Go to Model View
3.- Add an ECO Class called Invoice
4.- Add an attribute called number: String
5.- Add an ECO Class called InvoiceLine
6.- Add an attribute line: Integer
7.- Make an association 1 to many between Invoice and InvoiceLine
8.- In the Winform Configure an OclPSHandle with Expression
InvoiceLine.allInstances->orderBy(invoice.number)
9. Configure a BDP Connection and a persistenceMapperBDP
10. Configure an Datagrid DataSource OclPSHandle1
11. Put a button to fill data. i.e.

Invoice lInvoice;
InvoiceLine lInvoiceLine;
lInvoice = new Invoice(EcoSpace);
lInvoice.number = "A002";
lInvoiceLine = new InvoiceLine(EcoSpace);
lInvoiceLine.invoice = lInvoice;
lInvoiceLine.Line = 1;
lInvoiceLine = new InvoiceLine(EcoSpace);
lInvoiceLine.invoice = lInvoice;
lInvoiceLine.Line = 2;
lInvoice = new Invoice(EcoSpace);
lInvoice.number = "A001";
lInvoiceLine = new InvoiceLine(EcoSpace);
lInvoiceLine.invoice = lInvoice;
lInvoiceLine.Line = 3;
lInvoiceLine = new InvoiceLine(EcoSpace);
lInvoiceLine.invoice = lInvoice;
lInvoiceLine.Line = 4;

12.- Put a button to save data into the database
  EcoAction UpdateDatabase

13.- Put a button to execute the OclPSHandle

oPSInvoices.Execute();

That's it
Workarounds
None
Attachment
Project1.zip
Comments

None

Server Response from: ETNACODE01