blaze-persistence
blaze-persistence copied to clipboard
Generate a creatable-view-friendly constructor for entity views
Currently generated EntityViewImpl
constructors possess two properties that make them unusable for saving the new EV instances:
-
$$_isNew
returns false therefore the EV instance can't be saved - the full-arg constructor also requires
id
which doesn't make sense for fresh instances (it can be passed asnull
but that is ugly)
Please generate a new kind of full-arg constructor, e.g. EntityViewImplNew
, without id
and with $$_isNew
returning true.
Update: I realized that constructing an EV instance with an EntityViewImpl
constructor bypasses any listeners tied to the EV lifecycle (probably only @PostCreate
is relevant here). The solution should therefore ensure that at least @PostCreate
is run as well. The overall requirement basically is to have the fully featured EV construction (with defaults etc.) while avoiding unnecessary mutability.