Before detaching an object we check if it is an Entity