google-nomulus/core
Michael Muller eb1aeab223 Always detach entities during load (#1116)
* Always detach entities during load

The mutations on non-transient fields that we do in some of the PostLoad
methods have been causing the objects to be marked as "dirty", and hibernate
has been quietly persisting them during transaction commit.

By detaching the entities on load, we avoid any possibility of this, which
works in our case because we treat all of our model objects as immutable
during normal use.

There is another mixed blessing to this: lazy loading won't work on these
objects once they are detached from a session, meaning that all fields must be
lazy loaded up front.  This is unfortunate in that we don't always need those
lazy-loaded fields and there is a performance cost to loading them, but it is
also useful in that objects will now be complete when used outseide of the
transaction that loaded them (prior to this, an attempt to access a
lazy-loaded field after its transaction closed would have caused an error at
runtime).

* Changes requested in review

* A few improvements to test logic

* Deal with premature detachment of mutated objects

* Add unit tests, use a more specific exception

* Changes for review

- Deal with DomainDeleteFlow, which appears to be the only case in the
  codebase where we're doing a load-after-save.
- Display the object that is being loaded after save in the exception message.
- Add a TODO for figuring out why Eager loads aren't working as expected.

* Move the recurring billing event into a parameter

* Changes for review and rebase error fix

* Remove initialization of list entries

Remove initialization of list entries that we want to be lazy loaded (premium,
reserved, and claims lists).

* Post-rebase cleanups
2021-05-25 14:34:24 -04:00
..
gradle/dependency-locks Update GCL dependency to avoid security alert (#1139) 2021-05-17 13:21:26 -04:00
src Always detach entities during load (#1116) 2021-05-25 14:34:24 -04:00
WEB-INF/appengine-generated Enable Cloud SQL when Datastore is enabled for unit test (#502) 2020-03-10 12:26:25 -04:00
build.gradle Add methods to return subtypes of HistoryEntry when querying (#1172) 2021-05-24 11:36:11 -04:00
Dockerfile Build docker image of nomulus tool (#142) 2019-07-16 20:18:44 -04:00