You can easily do the retrieve in a microflow which you call from your java code. This is the cleanest and simplest way to accomplish this.
Hope this helps,
Andrej
Couple of things:
1-* Associations are always stored on the many side, so it’s not that you cannot see it, it just isn’t available on your side.
Mendix writes the retrieves for the users in this case. If you want to do it in Java, you’ll have to do a retrieve on contracts with an XPath that references the Account’s identifier.
In the java documentation you will find the method you need under ICore.retrieveXpathQuery.
Edit: Here’s how I believe your query will look
String myQuery = String.format("//%s[%s="+ account.getId().toString()+"]",Contact.entityName,Contact.MemberNames.Contact_Account.toString());
Hope this helps