JmixProperty support for List transient property

Hi team,

I have an entity Post and it has a @Transient List<String> reads field. This field will be populated when loading Post instance from DB in EntityLoadingEvent - load list of readers and write their names into the reads field:

var postReads = postReadService.getEntityList(ParamsMap.of("postId", post.getId()));
post.setReads(postReads.stream().map(PostRead::getReaderName).toList());

I’m directly using services exposed as REST API, but this transient field is not show in the response JSON. I guess this may related to serialization of JmixEntity. So I added @JmixProperty to this field:

  @JmixProperty
  @Transient
  private List<String> reads;

This works:
image

But it has drawback, when I click the entity designer of Post entity, it will change the field to plain String type:

  @Transient
  @JmixProperty
  private String reads;

I understand that @JmixProperty does not support List type of plain data types.

Questions:

  1. without @JmixProperty, how can I make a transient field show in REST response of service method registered in rest-services.xml?
  2. after add @JmixProperty to the List field, as long as I don’t click visual designer, is it safe to leave it there? any drawback in this approach?

Jmix version: 1.4.1
Jmix Studio plugin version: 1.4.1-222
IntelliJ version: IntelliJ IDEA 2022.2.3 (Ultimate Edition)

Hi Bryan,

Collections of basic types are not supported in Jmix entity attributes. Only these types are fully supported.

The fact that adding @JmixProperty to a List<String> attribute leads to returning this attribute by REST API is probably an accidental behavior.

I’ve created an issue because it’s a recurring requirement and we should implement it once and for all.

Thank you, Konstantin!