Accessing the Many entities of a One-to-Many association in a java action that is passed the One entity
Hello, A one to many association (Customer-Order) make's the Customer (the '1' side) the owner. In our case I associate a new Order to the Customer in a Customer maintenance screen. Before persisting, I send the Customer object to a java action to do some further calculations. (It is not really a Customer and an Order, but a complete different 1-* assoc. For simplicity I call it a Customer-Order). In the generated java proxy's the Order can acces the Customer (association) directly from the order by for instance getorder_customer(). From the Customer proxy there is no method to get the set of Orders belonging to this Customer directly from the Customer proxy. For this we have to use the Core.retrieveByPath() functionality. This is fine, but retrieves Orders from the database. But my Order is not persisted yet... In the Java action I'd like to get access to the Order object that is created in the screen, in memory, and which is not yet in the database. Just like the Customer object, which is passed as a page parameter to the java action. So I thought to change the 'ownership', but if I start tweaking the association parameters (owner both, reference-referenceset), the association completely changes. In other words, It appears that I can't create a 1-* association where the 1 side is the owner. Obviously I see the implictions if you would be able to retrieve the 'many' side with one getter (performance, I guess), but in my case this will never be more than 10 items. Is there a way to pass the 'many' entiy(ies) together with the '1' entity to a java action? (The real model is a financial entity (one) which is related to a limited but variable set of currency's (many). So for that reason there is no Order maintenance screen, which would make it a bit easier.)
Nol de Wit
Is it an option to retrieve the "orders' list in the microflow and passing the list to the java action?
Erwin 't Hoen
I'm not sure if I understand your approach entirely.
But, if there is an association like M.A (1<--*) M.B and it has been set correctly, you should be able to retrieve all B's using Core.retrieveByPath(<context>, A, 'M.B_A').
The result includes all non-persisted B's as well (if executed with the proper context).
In that case, I'd say that it is similar to doing a retrieve by association in a microflow.
Nevertheless, Erwin's option is probably better as it makes the JAVA action easier to understand and less error prone.