|
|
|
@ -19,7 +19,6 @@ import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
|
|
|
|
|
import com.liferay.portal.kernel.dao.orm.FinderCacheUtil; |
|
|
|
|
import com.liferay.portal.kernel.dao.orm.FinderPath; |
|
|
|
|
import com.liferay.portal.kernel.dao.orm.Query; |
|
|
|
|
import com.liferay.portal.kernel.dao.orm.QueryPos; |
|
|
|
|
import com.liferay.portal.kernel.dao.orm.QueryUtil; |
|
|
|
|
import com.liferay.portal.kernel.dao.orm.Session; |
|
|
|
|
import com.liferay.portal.kernel.exception.SystemException; |
|
|
|
@ -32,7 +31,6 @@ import com.liferay.portal.kernel.util.PropsKeys;
|
|
|
|
|
import com.liferay.portal.kernel.util.PropsUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.SetUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.StringBundler; |
|
|
|
|
import com.liferay.portal.kernel.util.StringPool; |
|
|
|
|
import com.liferay.portal.kernel.util.StringUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.UnmodifiableList; |
|
|
|
|
import com.liferay.portal.model.CacheModel; |
|
|
|
@ -85,215 +83,6 @@ public class SportelloPersistenceImpl extends BasePersistenceImpl<Sportello>
|
|
|
|
|
public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SportelloModelImpl.ENTITY_CACHE_ENABLED, |
|
|
|
|
SportelloModelImpl.FINDER_CACHE_ENABLED, Long.class, |
|
|
|
|
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); |
|
|
|
|
public static final FinderPath FINDER_PATH_FETCH_BY_ID = new FinderPath(SportelloModelImpl.ENTITY_CACHE_ENABLED, |
|
|
|
|
SportelloModelImpl.FINDER_CACHE_ENABLED, SportelloImpl.class, |
|
|
|
|
FINDER_CLASS_NAME_ENTITY, "fetchById", |
|
|
|
|
new String[] { Long.class.getName() }, |
|
|
|
|
SportelloModelImpl.ID_COLUMN_BITMASK); |
|
|
|
|
public static final FinderPath FINDER_PATH_COUNT_BY_ID = new FinderPath(SportelloModelImpl.ENTITY_CACHE_ENABLED, |
|
|
|
|
SportelloModelImpl.FINDER_CACHE_ENABLED, Long.class, |
|
|
|
|
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countById", |
|
|
|
|
new String[] { Long.class.getName() }); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the sportello where id = ? or throws a {@link portos.nextmind.NoSuchSportelloException} if it could not be found. |
|
|
|
|
* |
|
|
|
|
* @param id the ID |
|
|
|
|
* @return the matching sportello |
|
|
|
|
* @throws portos.nextmind.NoSuchSportelloException if a matching sportello could not be found |
|
|
|
|
* @throws SystemException if a system exception occurred |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Sportello findById(long id) |
|
|
|
|
throws NoSuchSportelloException, SystemException { |
|
|
|
|
Sportello sportello = fetchById(id); |
|
|
|
|
|
|
|
|
|
if (sportello == null) { |
|
|
|
|
StringBundler msg = new StringBundler(4); |
|
|
|
|
|
|
|
|
|
msg.append(_NO_SUCH_ENTITY_WITH_KEY); |
|
|
|
|
|
|
|
|
|
msg.append("id="); |
|
|
|
|
msg.append(id); |
|
|
|
|
|
|
|
|
|
msg.append(StringPool.CLOSE_CURLY_BRACE); |
|
|
|
|
|
|
|
|
|
if (_log.isWarnEnabled()) { |
|
|
|
|
_log.warn(msg.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
throw new NoSuchSportelloException(msg.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return sportello; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the sportello where id = ? or returns <code>null</code> if it could not be found. Uses the finder cache. |
|
|
|
|
* |
|
|
|
|
* @param id the ID |
|
|
|
|
* @return the matching sportello, or <code>null</code> if a matching sportello could not be found |
|
|
|
|
* @throws SystemException if a system exception occurred |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Sportello fetchById(long id) throws SystemException { |
|
|
|
|
return fetchById(id, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the sportello where id = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. |
|
|
|
|
* |
|
|
|
|
* @param id the ID |
|
|
|
|
* @param retrieveFromCache whether to use the finder cache |
|
|
|
|
* @return the matching sportello, or <code>null</code> if a matching sportello could not be found |
|
|
|
|
* @throws SystemException if a system exception occurred |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Sportello fetchById(long id, boolean retrieveFromCache) |
|
|
|
|
throws SystemException { |
|
|
|
|
Object[] finderArgs = new Object[] { id }; |
|
|
|
|
|
|
|
|
|
Object result = null; |
|
|
|
|
|
|
|
|
|
if (retrieveFromCache) { |
|
|
|
|
result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_ID, |
|
|
|
|
finderArgs, this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result instanceof Sportello) { |
|
|
|
|
Sportello sportello = (Sportello)result; |
|
|
|
|
|
|
|
|
|
if ((id != sportello.getId())) { |
|
|
|
|
result = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result == null) { |
|
|
|
|
StringBundler query = new StringBundler(3); |
|
|
|
|
|
|
|
|
|
query.append(_SQL_SELECT_SPORTELLO_WHERE); |
|
|
|
|
|
|
|
|
|
query.append(_FINDER_COLUMN_ID_ID_2); |
|
|
|
|
|
|
|
|
|
String sql = query.toString(); |
|
|
|
|
|
|
|
|
|
Session session = null; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
session = openSession(); |
|
|
|
|
|
|
|
|
|
Query q = session.createQuery(sql); |
|
|
|
|
|
|
|
|
|
QueryPos qPos = QueryPos.getInstance(q); |
|
|
|
|
|
|
|
|
|
qPos.add(id); |
|
|
|
|
|
|
|
|
|
List<Sportello> list = q.list(); |
|
|
|
|
|
|
|
|
|
if (list.isEmpty()) { |
|
|
|
|
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ID, |
|
|
|
|
finderArgs, list); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
Sportello sportello = list.get(0); |
|
|
|
|
|
|
|
|
|
result = sportello; |
|
|
|
|
|
|
|
|
|
cacheResult(sportello); |
|
|
|
|
|
|
|
|
|
if ((sportello.getId() != id)) { |
|
|
|
|
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ID, |
|
|
|
|
finderArgs, sportello); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception e) { |
|
|
|
|
FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ID, finderArgs); |
|
|
|
|
|
|
|
|
|
throw processException(e); |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
|
closeSession(session); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result instanceof List<?>) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
return (Sportello)result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Removes the sportello where id = ? from the database. |
|
|
|
|
* |
|
|
|
|
* @param id the ID |
|
|
|
|
* @return the sportello that was removed |
|
|
|
|
* @throws SystemException if a system exception occurred |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Sportello removeById(long id) |
|
|
|
|
throws NoSuchSportelloException, SystemException { |
|
|
|
|
Sportello sportello = findById(id); |
|
|
|
|
|
|
|
|
|
return remove(sportello); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the number of sportellos where id = ?. |
|
|
|
|
* |
|
|
|
|
* @param id the ID |
|
|
|
|
* @return the number of matching sportellos |
|
|
|
|
* @throws SystemException if a system exception occurred |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public int countById(long id) throws SystemException { |
|
|
|
|
FinderPath finderPath = FINDER_PATH_COUNT_BY_ID; |
|
|
|
|
|
|
|
|
|
Object[] finderArgs = new Object[] { id }; |
|
|
|
|
|
|
|
|
|
Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs, |
|
|
|
|
this); |
|
|
|
|
|
|
|
|
|
if (count == null) { |
|
|
|
|
StringBundler query = new StringBundler(2); |
|
|
|
|
|
|
|
|
|
query.append(_SQL_COUNT_SPORTELLO_WHERE); |
|
|
|
|
|
|
|
|
|
query.append(_FINDER_COLUMN_ID_ID_2); |
|
|
|
|
|
|
|
|
|
String sql = query.toString(); |
|
|
|
|
|
|
|
|
|
Session session = null; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
session = openSession(); |
|
|
|
|
|
|
|
|
|
Query q = session.createQuery(sql); |
|
|
|
|
|
|
|
|
|
QueryPos qPos = QueryPos.getInstance(q); |
|
|
|
|
|
|
|
|
|
qPos.add(id); |
|
|
|
|
|
|
|
|
|
count = (Long)q.uniqueResult(); |
|
|
|
|
|
|
|
|
|
FinderCacheUtil.putResult(finderPath, finderArgs, count); |
|
|
|
|
} |
|
|
|
|
catch (Exception e) { |
|
|
|
|
FinderCacheUtil.removeResult(finderPath, finderArgs); |
|
|
|
|
|
|
|
|
|
throw processException(e); |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
|
closeSession(session); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return count.intValue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static final String _FINDER_COLUMN_ID_ID_2 = "sportello.id = ?"; |
|
|
|
|
|
|
|
|
|
public SportelloPersistenceImpl() { |
|
|
|
|
setModelClass(Sportello.class); |
|
|
|
@ -309,9 +98,6 @@ public class SportelloPersistenceImpl extends BasePersistenceImpl<Sportello>
|
|
|
|
|
EntityCacheUtil.putResult(SportelloModelImpl.ENTITY_CACHE_ENABLED, |
|
|
|
|
SportelloImpl.class, sportello.getPrimaryKey(), sportello); |
|
|
|
|
|
|
|
|
|
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ID, |
|
|
|
|
new Object[] { sportello.getId() }, sportello); |
|
|
|
|
|
|
|
|
|
sportello.resetOriginalValues(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -368,8 +154,6 @@ public class SportelloPersistenceImpl extends BasePersistenceImpl<Sportello>
|
|
|
|
|
|
|
|
|
|
FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); |
|
|
|
|
FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); |
|
|
|
|
|
|
|
|
|
clearUniqueFindersCache(sportello); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -380,48 +164,6 @@ public class SportelloPersistenceImpl extends BasePersistenceImpl<Sportello>
|
|
|
|
|
for (Sportello sportello : sportellos) { |
|
|
|
|
EntityCacheUtil.removeResult(SportelloModelImpl.ENTITY_CACHE_ENABLED, |
|
|
|
|
SportelloImpl.class, sportello.getPrimaryKey()); |
|
|
|
|
|
|
|
|
|
clearUniqueFindersCache(sportello); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void cacheUniqueFindersCache(Sportello sportello) { |
|
|
|
|
if (sportello.isNew()) { |
|
|
|
|
Object[] args = new Object[] { sportello.getId() }; |
|
|
|
|
|
|
|
|
|
FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ID, args, |
|
|
|
|
Long.valueOf(1)); |
|
|
|
|
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ID, args, sportello); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
SportelloModelImpl sportelloModelImpl = (SportelloModelImpl)sportello; |
|
|
|
|
|
|
|
|
|
if ((sportelloModelImpl.getColumnBitmask() & |
|
|
|
|
FINDER_PATH_FETCH_BY_ID.getColumnBitmask()) != 0) { |
|
|
|
|
Object[] args = new Object[] { sportello.getId() }; |
|
|
|
|
|
|
|
|
|
FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ID, args, |
|
|
|
|
Long.valueOf(1)); |
|
|
|
|
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ID, args, |
|
|
|
|
sportello); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void clearUniqueFindersCache(Sportello sportello) { |
|
|
|
|
SportelloModelImpl sportelloModelImpl = (SportelloModelImpl)sportello; |
|
|
|
|
|
|
|
|
|
Object[] args = new Object[] { sportello.getId() }; |
|
|
|
|
|
|
|
|
|
FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ID, args); |
|
|
|
|
FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ID, args); |
|
|
|
|
|
|
|
|
|
if ((sportelloModelImpl.getColumnBitmask() & |
|
|
|
|
FINDER_PATH_FETCH_BY_ID.getColumnBitmask()) != 0) { |
|
|
|
|
args = new Object[] { sportelloModelImpl.getOriginalId() }; |
|
|
|
|
|
|
|
|
|
FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ID, args); |
|
|
|
|
FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ID, args); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -559,16 +301,13 @@ public class SportelloPersistenceImpl extends BasePersistenceImpl<Sportello>
|
|
|
|
|
|
|
|
|
|
FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); |
|
|
|
|
|
|
|
|
|
if (isNew || !SportelloModelImpl.COLUMN_BITMASK_ENABLED) { |
|
|
|
|
if (isNew) { |
|
|
|
|
FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
EntityCacheUtil.putResult(SportelloModelImpl.ENTITY_CACHE_ENABLED, |
|
|
|
|
SportelloImpl.class, sportello.getPrimaryKey(), sportello); |
|
|
|
|
|
|
|
|
|
clearUniqueFindersCache(sportello); |
|
|
|
|
cacheUniqueFindersCache(sportello); |
|
|
|
|
|
|
|
|
|
return sportello; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -915,12 +654,9 @@ public class SportelloPersistenceImpl extends BasePersistenceImpl<Sportello>
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static final String _SQL_SELECT_SPORTELLO = "SELECT sportello FROM Sportello sportello"; |
|
|
|
|
private static final String _SQL_SELECT_SPORTELLO_WHERE = "SELECT sportello FROM Sportello sportello WHERE "; |
|
|
|
|
private static final String _SQL_COUNT_SPORTELLO = "SELECT COUNT(sportello) FROM Sportello sportello"; |
|
|
|
|
private static final String _SQL_COUNT_SPORTELLO_WHERE = "SELECT COUNT(sportello) FROM Sportello sportello WHERE "; |
|
|
|
|
private static final String _ORDER_BY_ENTITY_ALIAS = "sportello."; |
|
|
|
|
private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Sportello exists with the primary key "; |
|
|
|
|
private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Sportello exists with the key {"; |
|
|
|
|
private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = GetterUtil.getBoolean(PropsUtil.get( |
|
|
|
|
PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE)); |
|
|
|
|
private static Log _log = LogFactoryUtil.getLog(SportelloPersistenceImpl.class); |
|
|
|
|