Java action - problems retrieving data using a database association

1
I'm attempting to retrieve a list of the applicants (people) associated with an application. I've successfully retrieved the application details and stored the application ID (not shown below). Now I'm trying to retrieve a list of the applicants associated with the application - using a Contact_Application association between ApplicationManagement.Contact and NewBusiness.Application. See code below. I'm getting an error because it looks like the below code is looking for a field called Contact_Application in ApplicationManagement.Contact - rather than using the Contact_Application association. I've based this on the Java sales order example https://world.mendix.com/display/howto40/Configure+Java+actions+using+Eclipse Have I misunderstood the example and am I going to have to manually retrieve details from the Contact_Application table, THEN retrieve details from the Contact table, or is there a better way of doing this? Hope I've explained this OK. Thanks, Keith. // Get contact details List<IMendixObject> NBapplicants = Core.retrieveXPathQueryEscaped(this.getContext(), "//%s[%s = %s]", "ApplicantManagement.Contact", "Contact_Application", applicationID); for (IMendixObject iMendixObject2: NBapplicants) { Contact contact = Contact.initialize(this.getContext(), iMendixObject2); Core.getLogger("Applicant").info(contact.getFullName()); }
asked
1 answers
4

You'll need to include the module name as well ( "Contact.Contact_Application").

But I would recommend using the proxy classes for this. This can be done using the following code:

List<IMendixObject> NBapplicants = Core.retrieveXPathQueryEscaped(this.getContext(), 
   "//%s[%s = %s]", 
   Contact.entityname, 
   Contact.MemberNames.Contact_Application.toString(), 
   applicationID);

If you use the proxy classes for this any errors in the member names will show up as compile error instead of as runtime error. Let's say you would rename your contact entity or relationship you would not know your code was broken until you execute it. When using the proxy classes you would get a compile error because the proxy value no longer exists.

answered