Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
quote:
Originally posted by:
busitech
Our Java naturally classes contain properties which are
relationships to other classes - either one to many or many to one.
Due to the fact that these relationships are so intertwined, many
given objects end up referencing a large portion of the database if
one were to recursively follow all of the nested relationships. As
such, we desire to have the option of not loading certain
relationships when the data is not needed.
We use EJB 3.0 (JBoss implementation using Hibernate) for
object persistence. It allows the option of uninitialized
collections and other referenced objects.
The Flex process of serialization to AMF causes serious
problems for this design. It tries to touch all of these properties
while building the binary representation for sending over the wire.
This triggers an immediate attempt to initialize the objects which
are still in the uninitialized state.
This causes the LazyInitializationException to be thrown by
the O/R framework - because the transaction is already closed
(which effectively means the call to the DAO has returned).
The community only offers two suggestions, both which do not
work with Flex (or Flash Remoting for that matter). T
he first is simply initializing everything ahead of time.
This does not work because eventually you have to draw the line
somewhere, and the Flex serialization routines will find that line
and try to cross it.
The second is the open session in view pattern, meaning that
we open the transaction as soon as the Flex client makes a request,
and close it only when the last response has been made. This does
not work either, because Flex would end up initializing everything
during serialization.
I have gone to the extent to writing a custom aspect to
intercept returning calls from my DAO and null out the Hibernate
proxies. This worked until I tried to use it for uninitialized many
to one relationships. Nulling them out actually deletes my
relationship in the database!
The only solution I see is to add intelligence to the Flex
serialization techniques which watch for this scenario, and avoid
triggering the lazy initialization.
Any suggestions would be appreciated.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies