users@jpa-spec.java.net

[jpa-spec users] [jsr338-experts] Re: Proposal for EntityGraphs, fetch plans, etc...

From: Emmanuel Bernard <ebernard_at_redhat.com>
Date: Mon, 17 Dec 2012 10:25:48 +0100

> >## Use cases
> >
> >I would really like to get use cases associated to each of the new
> >features proposed here.
> >
> >In particular:
> >- it's unclear to me why you really need loadgraph and fetchgraph.
> >- why is merge( fetchgraph ) required when you can achieve the same with
> > - find( fetchgraph )
> > - detach / serialize or whatever
> > - merge() regular method
> merge(EntityGraph) applies when the user is using copy(EntityGraph)
> to detach an entity tree for serialization. If an attribute is not
> present in the copy then it must not be merged. So, your example
> becomes:
> - find (EntityGraph eg1)
> - copy(EntityGraph eg1)
> - serialize out/in
> - merge(EntityGraph eg1)

Sure but the graph returned by copy does contain guards on uninitialized
properties and associations right? Ie when a non copied property /
association is traversed, some exception is raised.

If that's not the case then what are you returning? null or the
primitive default values? I would be strongly against that.

So assuming the engine has those guards on uninitialized properties and
associations, then the merge with an EntityGraph is not necessary as
this information can be discovered (like we do for a regular merge).

Emmanuel