I’m wondering what’s the rule related to @OneToMany
fields when received in EntitySavingEvent
? Like in what situation will I get what, because otherwise things turn wired.
My JMix version is 2.3.0
, I’m both manipulating the entity on webpage, having API access to entity using REST plugin, and saving another entity in one entity. Currently I’ve found following situations for @OneToMany List<...>
fields provided by EntitySavingEvent.getEntity()
:
null
-
IndirectList
: a list, but will error on any operation (e.g.isEmpty()
) on it - an empty list: does this mean it’s actually empty or it’s not initialized?
- a regular list: does this mean content inside is fully initialized, or they can also be:
null
/SomeIndirectObject
? In case of indirect object, can their id be accessed throughId.of(...)
/getId()
, or those ids are not accessible through simple methods?
Since all kinds of error can happen, now I always try to dataManager.load
related entity before trying to access something inside, but there are situation where the entity is not saved yet or the incoming entity contains update, so the logic become really messy.
Any systematic way of dealing with these situations? Thanks!