7980818283848586878889
try { userPrefs = em.find(UserPrefs.class, user.getUserId()); if (userPrefs == null) { userPrefs = new UserPrefs(user); } else { userPrefs.cacheSet(); } } finally { em.close(); }