@Override protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath) { userTrackerPath = toUnwrappedModel(userTrackerPath); Session session = null; try { session = openSession(); if (!session.contains(userTrackerPath)) { userTrackerPath = (UserTrackerPath) session.get(UserTrackerPathImpl.class, userTrackerPath.getPrimaryKeyObj()); } if (userTrackerPath != null) { session.delete(userTrackerPath); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (userTrackerPath != null) { clearCache(userTrackerPath); } return userTrackerPath; }
@Override public Map<Serializable, UserTrackerPath> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, UserTrackerPath> map = new HashMap<Serializable, UserTrackerPath>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey); if (userTrackerPath != null) { map.put(primaryKey, userTrackerPath); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { UserTrackerPath userTrackerPath = (UserTrackerPath) EntityCacheUtil.getResult( UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED, UserTrackerPathImpl.class, primaryKey); if (userTrackerPath == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, userTrackerPath); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (UserTrackerPath userTrackerPath : (List<UserTrackerPath>) q.list()) { map.put(userTrackerPath.getPrimaryKeyObj(), userTrackerPath); cacheResult(userTrackerPath); uncachedPrimaryKeys.remove(userTrackerPath.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult( UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED, UserTrackerPathImpl.class, primaryKey, _nullUserTrackerPath); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }