@FetchConfig#

com.palmyralabs.palmyra.base.annotations.FetchConfig

Controls how much of a parent (referenced) object is fetched when its owning row is read. Target: FIELD. Retention: RUNTIME.

Applies to parent references only. @FetchConfig has no effect on child collections — child attributes are always fetched under the current framework behaviour. Apply the annotation to the field that holds the parent/FK reference.

Attributes#

Attribute Signature
fetchMode FetchMode fetchMode() default FetchMode.ALL

FetchMode#

com.palmyralabs.palmyra.base.format.FetchMode

Constant Wire value What comes back from the parent
ALL "all" Every attribute of the parent (default)
PRIMITIVE_FIELDS "primitive" Scalar / primitive columns only — no nested references
KEY_FIELDS "keyfield" Just the fields flagged as key (@PalmyraField(keyField = true) / primary key)
PRIMITIVE_OR_KEY_FIELDS "primitive_key" Union of the two — primitives plus key fields

Use PRIMITIVE_OR_KEY_FIELDS when the UI needs a display label (a primitive name/code) plus an id (a key field), but no further joins. Use KEY_FIELDS when only the id is needed — useful for light-weight list payloads.

Example#

@PalmyraType(type = "Order")
public class Order {

    @PalmyraField private Integer id;

    // Full customer object — default behaviour
    @PalmyraField(attribute = "customer")
    @FetchConfig(fetchMode = FetchMode.ALL)
    private CustomerModel customer;

    // Manufacturer reference: return id + name only, not the nested Manufacturer.parent, .address, etc.
    @PalmyraField(attribute = "manufacturer")
    @FetchConfig(fetchMode = FetchMode.PRIMITIVE_OR_KEY_FIELDS)
    private ManufacturerModel manufacturer;

    // Warehouse reference: id only — the UI already has the label cached
    @PalmyraField(attribute = "warehouse")
    @FetchConfig(fetchMode = FetchMode.KEY_FIELDS)
    private WarehouseModel warehouse;
}

Smaller fetch modes trim the JOIN list the framework generates — a common way to shrink payload size on high-volume list endpoints without writing custom DTOs.