Menu

Welcome to Open Discussion

2010-05-02
2013-04-25
  • Alan N. Lohse

    Alan N. Lohse - 2010-05-02

    Welcome to Open Discussion

     
  • Martin Dames

    Martin Dames - 2010-08-05

    Hi, thank you for the library.

    But I get errors by deepCloneSerialization:

    org.cloner.CloneException: java.io.StreamCorruptedException: invalid stream header

    it seems to be an internal exception of Cloner… all my objects are Serializable… and I can do a deepClone with org.hibernate.util.SerializationHelper.

    Another question:

    You wrote "It is useful if you need to deattach an entity from an EntityManager."
    So, all my objects are not detached and all are having ids (from hibernate). So, I need to have a deepClone with all id's resetted to null, so that I can persist the whole object graph again as a copy. Did you mean this with your statement?

     
  • Alan N. Lohse

    Alan N. Lohse - 2011-03-06

    If you need to clone a object graph use deepClone(Object bean, Class<?> clazz). It will clone all and deattach it from an EntityManager. Deattach an object won't clear its ids, it will just fetch all lazy data and eliminating any problem with lazy fetch. But be careful it can down your performance.

     
  • Alan N. Lohse

    Alan N. Lohse - 2011-03-06

    The deepCloneSerialized perform a deep clone but it doesn't deattach because it is like a picture of the original object. some things may contain data that are lost in this process. There are two methods available for cloning objects, choose one that best fits your needs

     

Log in to post a comment.

MongoDB Logo MongoDB