private Element disableLazyLoaders(Element anElement) 
  throws Exception {
    ByteArrayOutputStream myBuffer = new ByteArrayOutputStream();
    
    ObjectOutputStream myObjectOutputStream = new ObjectOutputStream(myBuffer);
    myObjectOutputStream.writeObject(anElement);
    myObjectOutputStream.close();
    
    myBuffer.close();
    
    ObjectInputStream myObjectInputStream = new ObjectInputStream(new ByteArrayInputStream(myBuffer.toByteArray()));
    Element myResult = (Element)myObjectInputStream.readObject();
    myObjectInputStream.close();
    
    return myResult;
  }
Disable lazy loaders by serializing / deserializing the element
src/test/java/org/apache/ibatis/submitted/automatic_lazy_loading/AutomaticLazyLoadingTest.java