On 7/23/07, IvanLatysh <[EMAIL PROTECTED]> wrote:
Marcel Reutegger wrote: > I agree with you that this not intuitive but returning a node with the > persistent state is IMO worse. > > Let say you have a node A. Then you set property p which gives you A' > (the transiently modified A). Then you query the workspace for nodes > with property p and the value you just set. The query would then return > node A. Now you modify that very same node instance and set property q > to another value. Will this result in A''? What happens to A'? What > happens if you call refresh() on A'' will it also refresh A'? What will > be persisted if you call Session.save(), A' or A'' or modifications from > both? Assuming it were possible that you *can* save just A', does a save > on A'' throw a InvalidItemStateException? If I had the time I could > probably go one for minutes and write down more of those tricky questions. If I understood you correctly: 1) query repository for node with property P=steve 2) got node A with property P=steve 3) set node A property P=john (making it transient) 4) query repository for node with property P=john 5) got node A (transient) with property P=john 6) set property Q=test
No he's talking about what would happen if you return persisted nodes from queries, more like you said below: What you missed is that every time query will return the same transient
state, so no A' and A'' will ever exist, and node A persisted with all changes. If query return persistent state only you will see a bit different behavior. 1) query repo for node with property P=steve 2) got node A with property P=steve 3) set node A property P=john (making it transient) 4) query repository for node with property P=john 5) got nothing 6) query repo for node with property P=steve 7) got node A' (since A is a transient at this moment) with property P=steve
No, changing node A makes it A', remember it's different now from the node A that is persisted because you haven't saved it yet! So to change your example: If query return persistent state only you will see a bit different behavior. 1) query repo for node with property P=steve 2) got node A with property P=steve 3) set node A property P=john (making it transient, resulting in node A') 4) query repository for node with property P=john 5) got nothing 6) query repo for node with property P=steve 7) got node A (the original from the store because A' is still transient) with property P=steve And what Marcel was trying to say was: 8) set node A property Q=test (making it transient, resulting in node A'' because it's not the same as the one in the store and also different from A'? Or does something else happen?) 9) What happens when we call save() or refresh() on A' or A''? At least that's what I think he was trying to say :-) Cheers, -Tako
