Skip to content

Non-persistent entity attributes are exposed to the model and pass JPQL validation #5646

Description

@Flaurite

Environment

Jmix version: 3.0

Bug Description

The domain-model discovery tools of the AI Tools add-on expose every attribute of an entity, including non-persistent ones declared with @JmixProperty on a @Transient field or on a getter (for example, a computed full name or a calculated flag). Such attributes are listed among the regular properties in the entity summary. In the detailed domain model they carry persistent: false, but nothing explains to the model what the flag means, and JPQL validation does not check it.

As a result, the model treats the attribute as a regular column, puts it into the query, the query passes validation and is executed, and the execution fails because the attribute does not exist in the database.

Attributes with @InstanceName on a getter without @JmixProperty are not affected: they are not part of the metamodel and are not exposed at all.

Steps To Reproduce

  1. In an application with the AI Tools add-on, add a non-persistent attribute to an entity, for example to User:
    @JmixProperty
    @Transient
    private Boolean vip;
  2. In the AI chat, ask: "Show me one user with the vip field".

Current Behavior

aitls_getAvailableEntities lists vip among the User properties. The model generates SELECT u.vip FROM User u, the query passes validation and is executed, and execution fails:

Problem compiling [SELECT u.vip FROM User u].
[7, 12] The state field path 'u.vip' cannot be resolved to a valid type.

The error text, including the JPQL, is returned to the model as the tool result, and the user gets a generic "problem retrieving data" answer or a retelling of the technical error, depending on the model. The metadata still lists the attribute, so the model has no reason not to try the same query again.

Expected Behavior

  • Attributes that cannot be used in JPQL are either not exposed to the model at all, or are exposed in a way that makes their limitation explicit to the model, in both the compact entity summary and the detailed domain model.
  • JPQL validation rejects a query that references a non-persistent attribute before execution, with guidance that tells the model to drop the attribute or use the persistent attributes it is derived from.
  • The user gets a meaningful answer rather than a failed query.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions