}
@SuppressWarnings("unchecked")
public <T> T detachCopy(T entity) {
assertNotCloseInvoked();
Compatibility compat = this.getConfiguration().
getCompatibilityInstance();
boolean copyOnDetach = compat.getCopyOnDetach();
boolean cascadeWithDetach = compat.getCascadeWithDetach();
// Set compatibility options to get 1.x detach behavior
compat.setCopyOnDetach(true);
compat.setCascadeWithDetach(true);
try {
T t = (T)_broker.detach(entity, this);
return t;
} finally {
// Reset compatibility options
compat.setCopyOnDetach(copyOnDetach);
compat.setCascadeWithDetach(cascadeWithDetach);
}
}