The webapp I am working on uses OpenJPA (or Hibernate depending on bugs blocking
progress) and I have just hit a problem that currently looks like it will only
be solved by violating the current architecture.
I'm hoping I'm wrong and thought I'd ask first.
The scenario is that the user can choose a whole range of financial instruments
to put in a portfolio, and the webapp grabs them all on submission of the
request and builds the object graph.
The Manager class which is also the transactional interface then creates an
Analysis entity to hold performance stats, and which may create for itself a
large number of small child objects representing past performance.
When the Analysis is done, the Manager call finishes and the transaction commits
(or I commit the transaction in my unit test), and I get an out-of-memory
exception.
Presumably it's all the child object inserts causing the problem.
Obviously I would like to do a flush before I run out of memory, but the
Analysis entity object has no access to the entity manager. Or at least it
shouldn't have.
The other problem is that the Analysis entity can't really be saved until the
child objects are all created, so I would have to think of a dirty work-around
to allow me to save it first, to allow me to flush the child objects.
Can anybody give some advice?
Much appreciated
Adam