Detaching managed entity from entitymanager.

This code will detach a entity from hibernate Entitymanger making it thus unmanaged entity.

// Prepare workbook object to be used for cloning.
 Session session = (Session) entityManager.getDelegate();
 session.evict(workbook); // same as detached
 workbook.setId(null);

Leave a Comment

Your email address will not be published. Required fields are marked *