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. > >
