I am trying to run the following detached criteria query:
def e = new DetachedCriteria(Equipment).build {
eq('name', ef.name)
}.get()
but when I call e.isAttached() immediately afterward, I get true.
Background: I know I have an in-memory attached reference to Equipment e, but I want a detached reference to it, so that I can compare old database values to the in-memory set to see what has changed…
What you are creating here is not a detached query* – it’s an
Equipmentinstance. By adding theget()you are executing the query and producing an attachedEquipmentinstance. To create the detached query take away theget():and then later when you need to execute:
If you want to detach the
Equipmentinstance then you could call