How to get ManyToOne attribute id without fetching entire related entity?

@Entity
public class Order {
    ...
    @JoinColumn(name = "CLIENT_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Client client;
    ...

Jmix fetch CLIENT_ID when fetching Order with any predefined fetch plan.
But order.getClient().getId() fetch entire Client entity.
How can I get only client id without extra database query ?
Jmix imposes the restriction on mapping annotations: Attribute annotations must be placed only on fields (AccessType.FIELD).
So I can not use JPA proxy object.

Hi,

You may use the io.jmix.data.ReferenceIdProvider for loading a reference id. See the javadoc for details.

Always got IllegalStateException “Entity must be in managed state”.
Both in service component or UI view controller.
Even entityStates.isManaged(getEditedEntity()) == false
How can I make entity or list of entities loaded by dataManager managed ?

Entities returned by DataManager are in detached state. In order to have them managed you should use EntityManager for loading entities.

See the following documentation sections:

https://docs.jmix.io/jmix/data-access/entity-manager.html
https://docs.jmix.io/jmix/data-access/transactions.html