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:
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:
- without
@JmixProperty
, how can I make a transient field show in REST response of service method registered in rest-services.xml? - 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)