List of usage examples for org.hibernate.criterion DetachedCriteria forEntityName
@SuppressWarnings("UnusedDeclaration") public static DetachedCriteria forEntityName(String entityName, String alias)
From source file:com.qcadoo.model.internal.search.SearchCriteriaImpl.java
License:Open Source License
public SearchCriteriaImpl(final DataDefinition dataDefinition, final String alias) { checkNotNull(dataDefinition);/*w w w. j a va 2 s . c o m*/ sourceDataDefinition = dataDefinition; criteria = DetachedCriteria .forEntityName(((InternalDataDefinition) dataDefinition).getFullyQualifiedClassName(), alias); }
From source file:com.rockagen.gnext.qo.QueryObject.java
License:Apache License
/** * Generate hibernate {@link DetachedCriteria} * //w w w .j a v a 2 s. c om * @param entityName * @param alias * @see DetachedCriteria * @see Restrictions */ public DetachedCriteria generateDetachedCriteria(String entityName, String alias) { return DetachedCriteria.forEntityName(entityName, alias); }
From source file:org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao.java
License:Open Source License
public List<FIN_FinancialAccount> getFilteredFinancialAccounts(String strPaymentMethodId, String strOrgId, String strCurrencyId, PaymentDirection paymentDirection) { final OBCriteria<FIN_FinancialAccount> obc = OBDal.getInstance().createCriteria(FIN_FinancialAccount.class, "acc"); obc.add(Restrictions.in("organization.id", OBContext.getOBContext().getOrganizationStructureProvider().getNaturalTree(strOrgId))); obc.setFilterOnReadableOrganization(false); Currency requiredCurrency = null; if (strCurrencyId != null && !strCurrencyId.isEmpty()) { DetachedCriteria multiCurrAllowed = DetachedCriteria .forEntityName(FinAccPaymentMethod.ENTITY_NAME, "fapm") .add(Restrictions.eqProperty(FinAccPaymentMethod.PROPERTY_ACCOUNT + ".id", "acc.id")); if (paymentDirection == PaymentDirection.IN || paymentDirection == PaymentDirection.EITHER) { multiCurrAllowed.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_PAYINISMULTICURRENCY, true)); }//from www . j a v a2s. c om if (paymentDirection == PaymentDirection.OUT || paymentDirection == PaymentDirection.EITHER) { multiCurrAllowed.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_PAYOUTISMULTICURRENCY, true)); } requiredCurrency = OBDal.getInstance().get(Currency.class, strCurrencyId); obc.add(Restrictions.or(Restrictions.eq(FIN_FinancialAccount.PROPERTY_CURRENCY, requiredCurrency), Subqueries.exists(multiCurrAllowed.setProjection(Projections.id())))); } if (strPaymentMethodId != null && !strPaymentMethodId.isEmpty()) { List<FinAccPaymentMethod> finAccsMethods = getObject(FIN_PaymentMethod.class, strPaymentMethodId) .getFinancialMgmtFinAccPaymentMethodList(); if (finAccsMethods.isEmpty()) { return (new ArrayList<FIN_FinancialAccount>()); } ExpressionForFinAccPayMethod exp = new ExpressionForFinAccPayMethod(); for (FinAccPaymentMethod finAccPayMethod : finAccsMethods) { boolean validPaymentDirection = true; if (paymentDirection == PaymentDirection.IN) { validPaymentDirection = finAccPayMethod.isPayinAllow(); } else if (paymentDirection == PaymentDirection.OUT) { validPaymentDirection = finAccPayMethod.isPayoutAllow(); } boolean validCurrency = true; if (requiredCurrency != null) { boolean multiCurrencyAllowed = false; if (paymentDirection == PaymentDirection.IN) { multiCurrencyAllowed = finAccPayMethod.isPayinIsMulticurrency(); } else if (paymentDirection == PaymentDirection.OUT) { multiCurrencyAllowed = finAccPayMethod.isPayoutIsMulticurrency(); } else if (paymentDirection == PaymentDirection.EITHER) { multiCurrencyAllowed = finAccPayMethod.isPayinIsMulticurrency() || finAccPayMethod.isPayoutIsMulticurrency(); } validCurrency = multiCurrencyAllowed || requiredCurrency.equals(finAccPayMethod.getAccount().getCurrency()); } if (validPaymentDirection && validCurrency) { exp.addFinAccPaymentMethod(finAccPayMethod); } } Criterion crit = exp.getCriterion(); if (crit != null) { obc.add(crit); } else { return new ArrayList<FIN_FinancialAccount>(); } } return obc.list(); }