use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarLocalServiceImpl method massUpdate.
public void massUpdate() {
ActionableDynamicQuery adq = getActionableDynamicQuery();
adq.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
@Override
public void addCriteria(DynamicQuery dynamicQuery) {
dynamicQuery.add(RestrictionsFactoryUtil.lt("field3", 100));
}
});
adq.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Bar>() {
@Override
public void performAction(Bar bar) {
int field3 = bar.getField3();
field3++;
bar.setField3(field3);
updateBar(bar);
}
});
try {
adq.performActions();
} catch (Exception exception) {
exception.printStackTrace();
}
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByUuid_Last.
/**
* Returns the last bar in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the last matching bar
* @throws NoSuchBarException if a matching bar could not be found
*/
@Override
public Bar findByUuid_Last(String uuid, OrderByComparator<Bar> orderByComparator) throws NoSuchBarException {
Bar bar = fetchByUuid_Last(uuid, orderByComparator);
if (bar != null) {
return bar;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchBarException(msg.toString());
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method remove.
/**
* Removes the bar with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the bar
* @return the bar that was removed
* @throws NoSuchBarException if a bar with the primary key could not be found
*/
@Override
public Bar remove(Serializable primaryKey) throws NoSuchBarException {
Session session = null;
try {
session = openSession();
Bar bar = (Bar) session.get(BarImpl.class, primaryKey);
if (bar == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchBarException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(bar);
} catch (NoSuchBarException nsee) {
throw nsee;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method fetchByUUID_G.
/**
* Returns the bar where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param useFinderCache whether to use the finder cache
* @return the matching bar, or <code>null</code> if a matching bar could not be found
*/
@Override
public Bar fetchByUUID_G(String uuid, long groupId, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] { uuid, groupId };
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof Bar) {
Bar bar = (Bar) result;
if (!Objects.equals(uuid, bar.getUuid()) || (groupId != bar.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_BAR_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
List<Bar> list = q.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(_finderPathFetchByUUID_G, finderArgs, list);
}
} else {
Bar bar = list.get(0);
result = bar;
cacheResult(bar);
}
} catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(_finderPathFetchByUUID_G, finderArgs);
}
throw processException(e);
} finally {
closeSession(session);
}
}
if (result instanceof List<?>) {
return null;
} else {
return (Bar) result;
}
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByUuid.
/**
* Returns an ordered range of all the bars where uuid = ?.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>BarModelImpl</code>.
* </p>
*
* @param uuid the uuid
* @param start the lower bound of the range of bars
* @param end the upper bound of the range of bars (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bars
*/
@Override
public List<Bar> findByUuid(String uuid, int start, int end, OrderByComparator<Bar> orderByComparator, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] { uuid };
}
} else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] { uuid, start, end, orderByComparator };
}
List<Bar> list = null;
if (useFinderCache) {
list = (List<Bar>) finderCache.getResult(finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Bar bar : list) {
if (!uuid.equals(bar.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2));
} else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_BAR_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
} else {
query.append(BarModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
list = (List<Bar>) QueryUtil.list(q, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
} catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
Aggregations