本文整理匯總了Java中org.hibernate.criterion.Projections類的典型用法代碼示例。如果您正苦於以下問題:Java Projections類的具體用法?Java Projections怎麽用?Java Projections使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Projections類屬於org.hibernate.criterion包,在下文中一共展示了Projections類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAppsOfDropMarket
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
public List<App> getAppsOfDropMarket(Session session, String marketName, Integer currentPage, Integer pageSize) {
ProjectionList proList = Projections.projectionList();
proList.add(Projections.property("pkname"));
proList.add(Projections.property("signatureSha1"));
Criteria cri = session.createCriteria(App.class);
cri.setProjection(proList);
cri.setMaxResults(pageSize);
cri.setFirstResult(HibernateHelper.firstResult(currentPage, pageSize));
List<Object[]> list = HibernateHelper.list(cri);
List<App> apps = null;
if (list != null) {
apps = new ArrayList<App>(list.size());
for (Object[] obj : list) {
App e = new App();
e.setPkname((String) obj[0]);
e.setSignatureSha1((String) obj[1]);
apps.add(e);
}
list.clear();
}
return apps;
}
示例2: prepareItemQuery
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
public void prepareItemQuery(ItemSerializerState state)
{
final DetachedCriteria criteria = state.getItemQuery();
final ProjectionList projection = state.getItemProjection();
if( state.hasCategory(ItemSerializerService.CATEGORY_BASIC) )
{
projection.add(Projections.property("name.id"), NAME_ALIAS);
projection.add(Projections.property("description.id"), DESC_ALIAS);
}
if( state.hasCategory(ItemSerializerService.CATEGORY_METADATA) )
{
criteria.createAlias("itemXml", "itemXml");
projection.add(Projections.property("itemXml.xml"), METADATA_ALIAS);
}
}
示例3: getDownloadedSizeByUserSince
import org.hibernate.criterion.Projections; //導入依賴的package包/類
public long getDownloadedSizeByUserSince (final User user, final Date date)
{
Long result =
getHibernateTemplate ().execute (new HibernateCallback<Long> ()
{
@Override
public Long doInHibernate (Session session)
throws HibernateException, SQLException
{
Criteria criteria = session.createCriteria (
NetworkUsage.class);
criteria.setProjection (Projections.sum ("size"));
criteria.add (Restrictions.eq ("isDownload", true));
criteria.add (Restrictions.eq ("user", user));
criteria.add (Restrictions.gt ("date", date));
return (Long) criteria.uniqueResult ();
}
});
return (result == null) ? 0 : result;
}
示例4: getKeysImpl
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@SuppressWarnings("unchecked")
protected Collection<String> getKeysImpl(Session session, Long piid, String prefix, Type type) throws HibernateException {
if( piid == null )
return Collections.EMPTY_LIST;
Criteria criteria = session.createCriteria(getPersistentClass())
.add(Restrictions.eq("processInstanceId", piid))
.setProjection(Projections.property("key"));
if (prefix != null)
criteria.add(Restrictions.ilike("key", prefix, MatchMode.START));
if(type != null)
criteria.add(Restrictions.eq("type", type.getValue()));
return criteria.list();
}
示例5: getAllNewUsers
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
public List<String> getAllNewUsers(){
Session session = HibernateUtil.getSession();
List<String> newUsers = new ArrayList<>();
Criteria criteria;
try {
criteria = session.createCriteria(User.class);
newUsers = criteria.add(Restrictions.like("approved", false)).setProjection(Projections.property("username")).list();
}
catch(HibernateException he) {
he.printStackTrace();
}finally {
session.close();
}
if(newUsers.isEmpty()) {
newUsers = null;
}
return newUsers;
}
示例6: getAllPromotees
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<String> getAllPromotees(){
Session session = HibernateUtil.getSession();
List<String> promotees = new ArrayList<>();
Criteria criteria;
try {
criteria = session.createCriteria(User.class);
promotees = criteria.add(Restrictions.ge("avgScore", 70.0))
.add(Restrictions.like("approved", true))
.setProjection(Projections.property("username")).list();
}
catch(HibernateException he) {
he.printStackTrace();
}finally {
session.close();
}
if(promotees.isEmpty()) {
promotees = null;
}
return promotees;
}
示例7: handleGetEcrfFieldMaxSelectionSetValueCount
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
protected long handleGetEcrfFieldMaxSelectionSetValueCount(Long trialId) throws Exception {
org.hibernate.Criteria inputFieldCriteria = createInputFieldCriteria();
inputFieldCriteria.add(
Restrictions.in("fieldType", SELECT_FIELD_TYPES)); // no AUTOCOMPLETE!
org.hibernate.Criteria ecrfFieldCriteria = inputFieldCriteria.createCriteria("ecrfFields", "ecrfFields0", CriteriaSpecification.INNER_JOIN);
ecrfFieldCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
org.hibernate.Criteria selectionSetValueCriteria = inputFieldCriteria.createCriteria("selectionSetValues","inputFieldSelectionSetValues", CriteriaSpecification.INNER_JOIN);
inputFieldCriteria.setProjection(Projections.projectionList()
.add(Projections.groupProperty("ecrfFields0.id"))
.add(Projections.alias(Projections.count("inputFieldSelectionSetValues.id"),"selectionSetValuesCount")));
inputFieldCriteria.addOrder(Order.desc("selectionSetValuesCount"));
inputFieldCriteria.setMaxResults(1);
long maxSelectionSetValues = 0l;
try {
maxSelectionSetValues = (Long) ((Object[]) inputFieldCriteria.list().iterator().next())[1];
} catch (Exception e) {
}
return maxSelectionSetValues;
}
示例8: handleGetCount
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
protected long handleGetCount(
Long userId, PermissionProfile profile, PermissionProfileGroup profileGroup, Boolean active)
throws Exception {
org.hibernate.Criteria userPermissionProfileCritria = createUserPermissionProfileCriteria();
if (userId != null) {
userPermissionProfileCritria.add(Restrictions.eq("user.id", userId.longValue()));
}
if (profile != null) {
userPermissionProfileCritria.add(Restrictions.eq("profile", profile));
}
if (profileGroup != null) {
userPermissionProfileCritria.add(Restrictions.in("profile", PermissionProfileGrouping.getProfilesFromPermissionProfileGroup(profileGroup)));
}
if (active != null) {
userPermissionProfileCritria.add(Restrictions.eq("active", active.booleanValue()));
}
return (Long) userPermissionProfileCritria.setProjection(Projections.rowCount()).uniqueResult();
}
示例9: handleGetCount
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
protected long handleGetCount(Long probandListEntryId, Long ecrfId, String section, boolean excludeAuditTrail, Boolean optional) throws Exception {
org.hibernate.Criteria ecrfFieldValueCriteria = createEcrfFieldValueCriteria("ecrfFieldValue0");
// if (probandListEntryId != null) {
ecrfFieldValueCriteria.add(Restrictions.eq("listEntry.id", probandListEntryId.longValue()));
// }
org.hibernate.Criteria ecrfFieldCriteria = ecrfFieldValueCriteria.createCriteria("ecrfField", "ecrfField0"); // , CriteriaSpecification.INNER_JOIN);
ecrfFieldCriteria.add(Restrictions.eq("ecrf.id", ecrfId.longValue()));
// if (series != null) {
// ecrfFieldCriteria.add(Restrictions.eq("series", series.booleanValue()));
// }
if (optional != null) {
ecrfFieldCriteria.add(Restrictions.eq("optional", optional.booleanValue()));
}
if (section != null && section.length() > 0) {
ecrfFieldCriteria.add(Restrictions.eq("section", section));
} else {
ecrfFieldCriteria.add(Restrictions.or(Restrictions.eq("section", ""), Restrictions.isNull("section")));
}
if (excludeAuditTrail) {
applyEcrfFieldValueMaxIdSubCriteria(ecrfFieldValueCriteria, ecrfFieldCriteria, null, probandListEntryId, null);
}
return (Long) ecrfFieldValueCriteria.setProjection(Projections.rowCount()).uniqueResult();
}
示例10: handleGetCount
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
protected long handleGetCount(Long inventoryId, Long probandId, Long trialId,
Long courseId, Long onBehalfOfId) throws Exception {
Criteria bookingCriteria = createBookingCriteria();
if (inventoryId != null) {
bookingCriteria.add(Restrictions.eq("inventory.id", inventoryId.longValue()));
}
if (probandId != null) {
bookingCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
}
if (trialId != null) {
bookingCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
}
if (courseId != null) {
bookingCriteria.add(Restrictions.eq("course.id", courseId.longValue()));
}
if (onBehalfOfId != null) {
bookingCriteria.add(Restrictions.eq("onBehalfOf.id", onBehalfOfId.longValue()));
}
return (Long) bookingCriteria.setProjection(Projections.rowCount()).uniqueResult();
}
示例11: pageAdminsByConditions
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public Pagination<AdminDO> pageAdminsByConditions(Integer pageIndex, Integer pageSize, Map<String, Object> params){
//獲取記錄總數
Criteria criteria = daoSupport.createCriteria(AdminDO.class);
//相當於 select count(uid)
criteria.setProjection(Projections.count("uid"));
//設置查詢條件
if (Objects.nonNull(params)) {
criteria.add(Restrictions.allEq(params));
}
criteria.add(Restrictions.eq("editEnable", Boolean.TRUE));
Long total = (Long) criteria.uniqueResult();
//開始查詢列表,首先清除count查詢所用Projection
criteria.setProjection(null);
criteria.setFirstResult((pageIndex - 1)* pageSize);
criteria.setMaxResults(pageIndex * pageSize);
List<AdminDO> admins = criteria.list();
Pagination<AdminDO> pagination = new Pagination<AdminDO>(Long.valueOf(pageIndex), Long.valueOf(pageSize), total);
pagination.setItems(admins);
return pagination;
}
示例12: handleGetCount
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
protected long handleGetCount(Long trialId, Boolean active, Boolean activeSignup, Long probandId) throws Exception {
org.hibernate.Criteria inquiryValueCriteria = createInquiryValueCriteria();
if (probandId != null) {
inquiryValueCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
}
if (trialId != null || active != null) {
org.hibernate.Criteria inquiryCriteria = inquiryValueCriteria.createCriteria("inquiry", CriteriaSpecification.INNER_JOIN);
if (trialId != null) {
inquiryCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
}
if (active != null) {
inquiryCriteria.add(Restrictions.eq("active", active.booleanValue()));
}
if (activeSignup != null) {
inquiryCriteria.add(Restrictions.eq("activeSignup", activeSignup.booleanValue()));
}
}
return (Long) inquiryValueCriteria.setProjection(Projections.rowCount()).uniqueResult();
}
示例13: getLast
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
public QuotePE getLast(String sigle) {
Session session = getSession();
DetachedCriteria maxDate = DetachedCriteria.forClass(QuotePE.class);
maxDate.add(Restrictions.eq("symbol", sigle));
maxDate.setProjection(Projections.max("creationDateTime"));
Criteria criteria = session.createCriteria(QuotePE.class);
criteria.add(Restrictions.eq("symbol", sigle));
criteria.add(Property.forName("creationDateTime").eq(maxDate));
QuotePE pe = (QuotePE) criteria.uniqueResult();
session.close();
return pe;
}
示例14: countForSearchingRolling
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
public long countForSearchingRolling(Short catalog, Integer subCatalog, String keywords) {
Criteria cri = getSession().createCriteria(Rollinfo.class);
Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
if (catalog != null) {
appCriteria.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
}
if (keywords != null && !keywords.isEmpty()) {
appCriteria.add(Restrictions.like("name", keywords, MatchMode.START));
}
cri.setProjection(Projections.rowCount());
List<Long> list = HibernateHelper.list(cri);
return list.get(0);
}
示例15: handleGetMaxIndex
import org.hibernate.criterion.Projections; //導入依賴的package包/類
@Override
protected Long handleGetMaxIndex(Long probandListEntryId, Long ecrfId, String section) throws Exception {
org.hibernate.Criteria ecrfFieldValueCriteria = createEcrfFieldValueCriteria(null);
if (probandListEntryId != null) {
ecrfFieldValueCriteria.add(Restrictions.eq("listEntry.id", probandListEntryId.longValue()));
}
ecrfFieldValueCriteria.add(Restrictions.isNotNull("index"));
org.hibernate.Criteria ecrfFieldCriteria = ecrfFieldValueCriteria.createCriteria("ecrfField");
ecrfFieldCriteria.add(Restrictions.eq("ecrf.id", ecrfId.longValue()));
ecrfFieldCriteria.add(Restrictions.eq("series", true));
if (section != null && section.length() > 0) {
ecrfFieldCriteria.add(Restrictions.eq("section", section));
} else {
ecrfFieldCriteria.add(Restrictions.or(Restrictions.eq("section", ""), Restrictions.isNull("section")));
}
return (Long) ecrfFieldValueCriteria.setProjection(Projections.max("index")).uniqueResult();
}