A frequently asked question about Portofino is whether it supports CRUD over queries with joins. The usual answer is that out of the box it doesn't. However, the real answer is more complex than that.

First of all, often joins are used to decode values, e.g. to show a person's name rather than their ID. That is handled with selection providers coupled with the "short name" feature.

When a join is actually needed to combine values from multiple tables to form a single logical entity, the built-in CRUD action cannot do the job. However, the CRUD action is designed in a way that makes it usable to access a variety of data sources, not just a HQL query. For example, you can have CRUD over LDAP or a web service. All the database-specific logic is confined in a subclass (CrudAction) while most of the generic logic resides in its abstract superclass, AbstractCrudAction. So, if you can hack some Groovy code, it is not terribly hard to come up with a CRUD action that can work over your join, with your logic.

Starting with Portofino 4.2, especially, this becomes quite simple. AbstractCrudAction handles more of the logic than it used to, reducing the amount of boilerplate to write and override, and a new special AggregateClassAccessor is available that can combine properties from multiple objects. An example is attached to this page: action.groovy(info) and configuration.xml(info).

With previous versions, there is more work to do. Without the specialized ClassAccessor, it is necessary to use a support bean to hold the data from the query. However, following the example you get when you create an empty FormAction, it shouldn't be too hard to adapt the above example.

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
action.groovy 4.9 kB 1 30-Jul-2015 12:49 alessio.stalla@manydesigns.com
configuration.xml 3.3 kB 1 30-Jul-2015 12:49 alessio.stalla@manydesigns.com
« This page (revision-4) was last changed on 11-Aug-2016 14:40 by alessio.stalla@manydesigns.com