Use EntityManager's clear() function instead of manually detaching.