use of com.liferay.blade.workflow.basic.model.Baz in project liferay-blade-samples by liferay.
the class BazPersistenceTest method testDynamicQueryByPrimaryKeyExisting.
@Test
public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
Baz newBaz = addBaz();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Baz.class, _dynamicQueryClassLoader);
dynamicQuery.add(RestrictionsFactoryUtil.eq("bazId", newBaz.getBazId()));
List<Baz> result = _persistence.findWithDynamicQuery(dynamicQuery);
Assert.assertEquals(1, result.size());
Baz existingBaz = result.get(0);
Assert.assertEquals(existingBaz, newBaz);
}
use of com.liferay.blade.workflow.basic.model.Baz in project liferay-blade-samples by liferay.
the class BazPersistenceImpl method fetchByUUID_G.
/**
* Returns the baz 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 retrieveFromCache whether to retrieve from the finder cache
* @return the matching baz, or <code>null</code> if a matching baz could not be found
*/
@Override
public Baz fetchByUUID_G(String uuid, long groupId, boolean retrieveFromCache) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = new Object[] { uuid, groupId };
Object result = null;
if (retrieveFromCache) {
result = finderCache.getResult(_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof Baz) {
Baz baz = (Baz) result;
if (!Objects.equals(uuid, baz.getUuid()) || (groupId != baz.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_BAZ_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<Baz> list = q.list();
if (list.isEmpty()) {
finderCache.putResult(_finderPathFetchByUUID_G, finderArgs, list);
} else {
Baz baz = list.get(0);
result = baz;
cacheResult(baz);
}
} catch (Exception e) {
finderCache.removeResult(_finderPathFetchByUUID_G, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
if (result instanceof List<?>) {
return null;
} else {
return (Baz) result;
}
}
use of com.liferay.blade.workflow.basic.model.Baz in project liferay-blade-samples by liferay.
the class BazPersistenceImpl method findAll.
/**
* Returns an ordered range of all the bazs.
*
* <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 and pagination is required (<code>start</code> and <code>end</code> are not <code>QueryUtil#ALL_POS</code>), then the query will include the default ORDER BY logic from <code>BazModelImpl</code>. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
* </p>
*
* @param start the lower bound of the range of bazs
* @param end the upper bound of the range of bazs (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of bazs
*/
@Override
public List<Baz> findAll(int start, int end, OrderByComparator<Baz> orderByComparator, boolean retrieveFromCache) {
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
pagination = false;
finderPath = _finderPathWithoutPaginationFindAll;
finderArgs = FINDER_ARGS_EMPTY;
} else {
finderPath = _finderPathWithPaginationFindAll;
finderArgs = new Object[] { start, end, orderByComparator };
}
List<Baz> list = null;
if (retrieveFromCache) {
list = (List<Baz>) finderCache.getResult(finderPath, finderArgs, this);
}
if (list == null) {
StringBundler query = null;
String sql = null;
if (orderByComparator != null) {
query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2));
query.append(_SQL_SELECT_BAZ);
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = query.toString();
} else {
sql = _SQL_SELECT_BAZ;
if (pagination) {
sql = sql.concat(BazModelImpl.ORDER_BY_JPQL);
}
}
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
if (!pagination) {
list = (List<Baz>) QueryUtil.list(q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
} else {
list = (List<Baz>) QueryUtil.list(q, getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
} catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
use of com.liferay.blade.workflow.basic.model.Baz in project liferay-blade-samples by liferay.
the class BazPersistenceImpl method remove.
/**
* Removes the baz with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the baz
* @return the baz that was removed
* @throws NoSuchBazException if a baz with the primary key could not be found
*/
@Override
public Baz remove(Serializable primaryKey) throws NoSuchBazException {
Session session = null;
try {
session = openSession();
Baz baz = (Baz) session.get(BazImpl.class, primaryKey);
if (baz == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchBazException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(baz);
} catch (NoSuchBazException nsee) {
throw nsee;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.blade.workflow.basic.model.Baz in project liferay-blade-samples by liferay.
the class BazPersistenceImpl method findByUuid_PrevAndNext.
/**
* Returns the bazs before and after the current baz in the ordered set where uuid = ?.
*
* @param bazId the primary key of the current baz
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next baz
* @throws NoSuchBazException if a baz with the primary key could not be found
*/
@Override
public Baz[] findByUuid_PrevAndNext(long bazId, String uuid, OrderByComparator<Baz> orderByComparator) throws NoSuchBazException {
uuid = Objects.toString(uuid, "");
Baz baz = findByPrimaryKey(bazId);
Session session = null;
try {
session = openSession();
Baz[] array = new BazImpl[3];
array[0] = getByUuid_PrevAndNext(session, baz, uuid, orderByComparator, true);
array[1] = baz;
array[2] = getByUuid_PrevAndNext(session, baz, uuid, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
Aggregations