Exactly I have googled a lot more and finally I see that getReference is
the only way to do it. I was wrong because initially I thought the post was
about JPA and not it was about hibernate then I found the load function.
Thanks of that I could rewatched the javadoc again with another eyes and I
have found this.

Thank you so much.

El dt., 10 març, 2015 a les 13:11, Jean-Louis Monteiro (<
[email protected]>) va escriure:

> Isn't that getReference()?
> This is the only standard option, isn't it?
>
> Pretty useful when you want to delete or to attach to a relationship
>
> --
> Jean-Louis Monteiro
> http://twitter.com/jlouismonteiro
> http://www.tomitribe.com
>
> On Tue, Mar 10, 2015 at 12:34 PM, Alex Soto <[email protected]> wrote:
>
> > Ok it was session.load which instantiate a proxy but not hit the DB. Now
> I
> > only need to figure out if this is possible in JPA hehehe, Thanks
> >
> > El dt., 10 març, 2015 a les 12:25, Alex Soto (<[email protected]>) va
> > escriure:
> >
> > > Hi guys,
> > >
> > > some years ago I wrote something about JPA and how to add a new entity
> to
> > > a many relationship in a performance way but now I can find it. Let me
> > > explain what I did.
> > >
> > > Let's say we have an entity A that have a many relationship to B. Now
> > > let's say that I want to add a new instance of B into A and I know the
> id
> > > of A.
> > >
> > > So I have two options, the first one is finding A by id and then add
> the
> > B
> > > entity. But this is not well performed because you are loading entity A
> > > with all its relationships in memory.
> > >
> > > But I remember that was an operation which creates a proxied A with an
> id
> > > but without containing anything filled, it was like all fields where
> > lazy,
> > > but in this way you could do something like B.setA(proxiedA); and
> save(B)
> > > without loading the A document at all.
> > >
> > > I cannot find this post and now I cannot remember the operation. Do you
> > > have any idea about what I am talking about? Maybe it was something
> > related
> > > to Hibernate and not JPA?
> > >
> > > Thank you so much.
> > >
> > >
> >
>

Reply via email to