blaze-persistence icon indicating copy to clipboard operation
blaze-persistence copied to clipboard

Generate a creatable-view-friendly constructor for entity views

Open david-kubecka opened this issue 2 years ago • 0 comments

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 as null 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.

david-kubecka avatar Jan 09 '23 10:01 david-kubecka