Java tutorial
package com.lm.lic.manager.hibernate; import java.util.Date; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; import org.hibernate.LockMode; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.LogicalExpression; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.springframework.context.ApplicationContext; import com.lm.lic.manager.util.GenUtil; /** * A data access object (DAO) providing persistence and search support for RequestForLicense * entities. Transaction control of the save(), update() and delete() operations can directly * support Spring container-managed transactions or they can be augmented to handle user-managed * Spring transactions. Each of these methods provides additional information for how to configure * it for the desired type of transaction control. * * @see com.lm.lic.manager.hibernate.RequestForLicense * @author Ibrahim Mustafa */ public class RequestForLicenseDAO extends AbstractSortableEntityDAO { private static final Log log = LogFactory.getLog(RequestForLicenseDAO.class); public static final String REQUESTOR = "requestor"; public static final String RESPONSE = "response"; public static final String NUM_REQUESTED = "numRequested"; public static final String NUM_RETURNED = "numReturned"; public static final String NUM_OVER_DRAFT = "numOverDraft"; public static final String LIC_KEYS = "licKeys"; public static final String TIME_REQUESTED = "timeRequested"; public static final String REQUESTOR_IP = "requestorIp"; public static final String NUM_DEVICE_REQUESTS = "numDeviceRequests"; public static final String DEVICE_ID = "deviceId"; public static final String ISV_PRODUCT_ID = "isvProductId"; public static final String REQ_ORDER_ID = "reqOrderId"; public static final String REQ_REF_ID = "reqRefId"; public static final String USER_FIRST_NAME = "userFirstName"; public static final String USER_LAST_NAME = "userLastName"; public static final String USER_EMAIL = "userEmail"; public static final String USER_PHONE = "userPhone"; public static final String USER_COUNTRY = "userCountry"; public static final String USER_COUNTRY_CODE = "userCountryCode"; public static final String USER_STATE = "userState"; public static final String USER_CITY = "userCity"; public static final String USER_ZIP = "userZip"; public static final String REQ_SIGNATURE = "reqSignature"; public static final String REQ_PRODUCT = "reqProduct"; public static final String REQ_PRODUCT_VERSION = "reqProductVersion"; public static final String SPECIAL_USER_ID = "specialUserId"; public static final String SHARED_SECRET = "sharedSecret"; public static final String PURCHASE_PRICE_USD = "purchasePriceUsd"; public static final String PARTNER_ID = "partnerId"; public static final String SALE_CURRENCY = "saleCurrency"; public static final String STATUS = "status"; public static final String ACTIVATION_CODE = "activationCode"; public static final String PROMOTION_CODE = "promotionCode"; public static final String ORDER_DATE = "orderDate"; public static final String CHANNEL = "channel"; public static final String AFFILIATE_ID = "affiliateId"; public static final String ACTION = "action"; public static final String SUBSCRIPTION_ID = "subscriptionId"; public static final String SUBSCRIPTION_EXPIRATION_ATE = "subscriptionExpirationAte"; public static final String CREATED_BY = "createdBy"; public static final String MODIFIED_BY = "modifiedBy"; @Override protected void initDao() { } public List<RequestForLicense> findIsvRequests(String isvId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { Long id = Long.parseLong(isvId); return findIsvRequests(id, firstResult, maxResults, orderBy, orderDir, null, null); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } public List<RequestForLicense> findIsvRequests(String isvId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { try { Long id = Long.parseLong(isvId); return findIsvRequests(id, firstResult, maxResults, orderBy, orderDir, startDate, endDate); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } @SuppressWarnings("unchecked") public List<RequestForLicense> findIsvRequests(Long isvId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<RequestForLicense> rfls = null; try { Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("isv.id", isvId)); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); createOrderByFieldAliasIfApplicable(orderBy, orderDir, criteria); rfls = criteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; } public List<RequestForLicense> findIsvProdRequests(String isvId, String prodId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { Long id = Long.parseLong(prodId); return findProdRequests(id, firstResult, maxResults, orderBy, orderDir); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } @SuppressWarnings("unchecked") public List<RequestForLicense> findIsvProdRequests(String isvId, String prodId, String prodDefId, String storeId, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<RequestForLicense> rfls = null; try { Criteria mainCriteria = getSession().createCriteria(RequestForLicense.class); ProductInstanceCriterias prodInstCriterias = addIsvProductInstProductDefStorePlatfrmCriteria(isvId, prodId, prodDefId, storeId, platformId, mainCriteria); mainCriteria.setFirstResult(firstResult); mainCriteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, mainCriteria); addOrderByToCriteria(orderBy, orderDir, mainCriteria, prodInstCriterias); rfls = mainCriteria.list(); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } return rfls; } @SuppressWarnings("unchecked") public List<RequestForLicense> findProdRequests(Long prodId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { List<RequestForLicense> rfls = null; try { String qs = "from RequestForLicense as rfl where rfl.product.id= :prodId order by rfl." + orderBy + " " + orderDir; Query query = getSession().createQuery(qs); query.setFirstResult(firstResult); query.setMaxResults(maxResults); query.setParameter("prodId", prodId); rfls = query.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; } public Integer findNumIsvRequests(String isvId, Date startDate, Date endDate) { Integer numRequests = 0; try { Long lisvid = Long.parseLong(isvId); Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("isv.id", lisvid)); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); criteria.setProjection(Projections.rowCount()); numRequests = (Integer) criteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numRequests; } public Integer findNumRequests(String isvId, String prodId, String prodDefId, String storeId, String platformId, Date startDate, Date endDate) { Integer numRequests = 0; try { Criteria mainCriteria = getSession().createCriteria(RequestForLicense.class); addIsvProductInstProductDefStorePlatfrmCriteria(isvId, prodId, prodDefId, storeId, platformId, mainCriteria); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, mainCriteria); mainCriteria.setProjection(Projections.rowCount()); numRequests = (Integer) mainCriteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numRequests; } public Integer findNumProdRequests(String prodId, Date startDate, Date endDate) { Integer numLics = 0; try { Long lpid = Long.parseLong(prodId); Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("product.id", lpid)); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); criteria.setProjection(Projections.rowCount()); numLics = (Integer) criteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numLics; } public List<RequestForLicense> findRequests(String isvId, String prodId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { return findIsvProdRequests(isvId, prodId, firstResult, maxResults, orderBy, orderDir); } public List<RequestForLicense> findProdRequests(String prodId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { Long id = Long.parseLong(prodId); return findProdRequests(id, firstResult, maxResults, orderBy, orderDir); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } // BEG GOOD SALES methods public List<RequestForLicense> findIsvGoodSales(String isvId, String store, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { return findIsvGoodSales(isvId, store, platformId, firstResult, maxResults, orderBy, orderDir, null, null); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } @SuppressWarnings("unchecked") public List<RequestForLicense> findIsvGoodSales(String isvId, String storeId, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<RequestForLicense> rfls = null; try { Criteria criteria = createCriteriaForClass(RequestForLicense.class); addIsvProductInstProductDefStorePlatfrmCriteria(isvId, null, null, storeId, platformId, criteria); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); createOrderByFieldAliasIfApplicable(orderBy, orderDir, criteria); rfls = criteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; } public List<RequestForLicense> findIsvProdGoodSales(String isvId, String prodId, String store, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { Long id = Long.parseLong(prodId); return findProdGoodSales(id, store, firstResult, maxResults, orderBy, orderDir); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } @SuppressWarnings("unchecked") public List<RequestForLicense> findIsvProdGoodSales(String isvId, String prodId, String prodDefId, String storeId, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<RequestForLicense> sales = null; try { Criteria mainCriteria = createCriteriaForClass(RequestForLicense.class); ProductInstanceCriterias prodInstCriterias = addIsvProductInstProductDefStorePlatfrmCriteria(isvId, prodId, prodDefId, storeId, platformId, mainCriteria); mainCriteria.setFirstResult(firstResult); mainCriteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, mainCriteria); // createOrderByFieldAliasIfApplicable(orderBy, orderDir, criteria); addOrderByToCriteria(orderBy, orderDir, mainCriteria, prodInstCriterias); sales = mainCriteria.list(); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } return sales; } @SuppressWarnings("unchecked") public List<RequestForLicense> findProdGoodSales(Long prodId, String store, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { List<RequestForLicense> rfls = null; try { String qs = "from RequestForLicense as rfl where rfl.product.id= :prodId and rfl.requestor= :requestor order by rfl." + orderBy + " " + orderDir; Query query = getSession().createQuery(qs); query.setFirstResult(firstResult); query.setMaxResults(maxResults); query.setParameter("prodId", prodId); query.setParameter("requestor", store); rfls = query.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; } public Integer findNumIsvGoodSales(String isvId, String store, Date startDate, Date endDate) { Integer numSales = 0; try { Long lisvid = Long.parseLong(isvId); Criteria criteria = getSession().createCriteria(RequestForLicense.class); Criterion isvIdCrit = Restrictions.eq("isv.id", lisvid); Criterion requestorCrit = Restrictions.eq("requestor", store); LogicalExpression andExp = Restrictions.and(isvIdCrit, requestorCrit); criteria.add(andExp); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); criteria.setProjection(Projections.rowCount()); numSales = (Integer) criteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numSales; } public Integer findNumGoodSales(String isvId, String prodId, String prodDefId, String storeId, String platformId, Date startDate, Date endDate) { Integer numSales = 0; try { Criteria criteria = createCriteriaForClass(RequestForLicense.class); addIsvProductInstProductDefStorePlatfrmCriteria(isvId, prodId, prodDefId, storeId, platformId, criteria); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); criteria.setProjection(Projections.rowCount()); numSales = (Integer) criteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numSales; } public Integer findNumProdGoodSales(String prodId, String store, Date startDate, Date endDate) { Integer numLics = 0; try { Long lpid = Long.parseLong(prodId); Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("product.id", lpid)); criteria.add(Restrictions.eq("requestor", store)); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); criteria.setProjection(Projections.rowCount()); numLics = (Integer) criteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numLics; } public List<RequestForLicense> findGoodSales(String isvId, String prodId, String store, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { return findIsvProdGoodSales(isvId, prodId, store, platformId, firstResult, maxResults, orderBy, orderDir); } public List<RequestForLicense> findProdGoodSales(String prodId, String store, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { Long id = Long.parseLong(prodId); return findProdGoodSales(id, store, firstResult, maxResults, orderBy, orderDir); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } // END GOOD SALES methods // BEG BAD SALES methods public List<RequestForLicense> findIsvBadSales(String isvId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { Long id = Long.parseLong(isvId); return findIsvBadSales(id, store, products, firstResult, maxResults, orderBy, orderDir, null, null); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } public List<RequestForLicense> findIsvBadSales(String isvId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { try { Long id = Long.parseLong(isvId); return findIsvBadSales(id, store, products, firstResult, maxResults, orderBy, orderDir, startDate, endDate); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } @SuppressWarnings("unchecked") public List<RequestForLicense> findIsvBadSales(Long isvId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<RequestForLicense> rfls = null; try { Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("requestor", store)); criteria.add(Restrictions.eq("response", "InProgress")); LogicalExpression orExp = createInProdNamesOrIsvProdIdsLogicalExp(products); if (orExp != null) criteria.add(orExp); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); createOrderByFieldAliasIfApplicable(orderBy, orderDir, criteria); rfls = criteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; } private LogicalExpression createInProdNamesOrIsvProdIdsLogicalExp(List<QuickyProduct> products) { List<String> isvProductIds = GenUtil.listIsvProductIds(products); List<String> productNames = GenUtil.listproductNames(products); LogicalExpression orExp = null; if (products != null && products.size() > 0) { Criterion inProdNamesCrit = Restrictions.in("reqProduct", productNames); Criterion isvInProdIdsCrit = Restrictions.in("isvProductId", isvProductIds); orExp = Restrictions.or(isvInProdIdsCrit, inProdNamesCrit); } return orExp; } public List<RequestForLicense> findIsvProdBadSales(String isvId, String prodId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { Long id = Long.parseLong(prodId); return findProdBadSales(id, store, products, firstResult, maxResults, orderBy, orderDir); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } public List<RequestForLicense> findIsvProdBadSales(String isvId, String prodId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { try { Long id = Long.parseLong(prodId); return findProdBadSales(id, store, products, firstResult, maxResults, orderBy, orderDir); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } @SuppressWarnings("unchecked") public List<RequestForLicense> findProdBadSales(Long prodId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { List<RequestForLicense> rfls = null; try { String qs = "from RequestForLicense as rfl where rfl.product.id= :prodId and rfl.requestor= :requestor " + "and rfl.response= :response order by rfl." + orderBy + " " + orderDir; Query query = getSession().createQuery(qs); query.setFirstResult(firstResult); query.setMaxResults(maxResults); query.setParameter("prodId", prodId); query.setParameter("requestor", store); query.setParameter("response", "InProgress"); rfls = query.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; } public Integer findNumIsvBadSales(String isvId, String store, List<QuickyProduct> products, Date startDate, Date endDate) { Integer numSales = 0; try { Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("requestor", store)); criteria.add(Restrictions.eq("response", "InProgress")); LogicalExpression orExp = createInProdNamesOrIsvProdIdsLogicalExp(products); if (orExp != null) criteria.add(orExp); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); criteria.setProjection(Projections.rowCount()); numSales = (Integer) criteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numSales; } public Integer findNumBadSales(String isvId, String prodId, String store, List<QuickyProduct> products, Date startDate, Date endDate) { Integer numSales = 0; try { Long lpid = Long.parseLong(prodId); Long lisvid = Long.parseLong(isvId); Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("isv.id", lisvid)); criteria.add(Restrictions.eq("product.id", lpid)); criteria.add(Restrictions.eq("requestor", store)); criteria.add(Restrictions.eq("response", "InProgress")); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); criteria.setProjection(Projections.rowCount()); numSales = (Integer) criteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numSales; } public Integer findNumProdBadSales(String prodId, String store, List<QuickyProduct> products, Date startDate, Date endDate) { Integer numLics = 0; try { Long lpid = Long.parseLong(prodId); Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("product.id", lpid)); criteria.add(Restrictions.eq("requestor", store)); criteria.add(Restrictions.eq("response", "InProgress")); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); criteria.setProjection(Projections.rowCount()); numLics = (Integer) criteria.list().get(0); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return numLics; } public List<RequestForLicense> findBadSales(String isvId, String prodId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { return findIsvProdBadSales(isvId, prodId, store, products, firstResult, maxResults, orderBy, orderDir); } public List<RequestForLicense> findProdBadSales(String prodId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { try { Long id = Long.parseLong(prodId); return findProdBadSales(id, store, products, firstResult, maxResults, orderBy, orderDir); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } } // END BAD SALES methods public void save(RequestForLicense transientInstance) { log.debug("saving RequestForLicense instance"); try { getHibernateTemplate().save(transientInstance); log.debug("save successful"); } catch (RuntimeException re) { log.error("save failed", re); throw re; } } public void delete(RequestForLicense persistentInstance) { log.debug("deleting RequestForLicense instance"); try { getHibernateTemplate().delete(persistentInstance); log.debug("delete successful"); } catch (RuntimeException re) { log.error("delete failed", re); throw re; } } public RequestForLicense findById(java.lang.Long id) { log.debug("getting RequestForLicense instance with id: " + id); try { RequestForLicense instance = (RequestForLicense) getHibernateTemplate() .get("com.lm.lic.manager.hibernate.RequestForLicense", id); return instance; } catch (RuntimeException re) { log.error("get failed", re); throw re; } } @SuppressWarnings("unchecked") public RequestForLicense findByPinAndKey(String deviceId, String licKey) { RequestForLicense rfl = null; try { String qs = "from RequestForLicense as rfl where rfl.deviceId= :deviceId and :licKey in rfl.licKeys"; Query query = getSession().createQuery(qs); query.setParameter("deviceId", deviceId); query.setParameter("licKey", licKey); query.setMaxResults(1); List<RequestForLicense> rfls = query.list(); if (rfls != null && rfls.size() > 0) rfl = rfls.get(0); } catch (RuntimeException re) { log.error("findByPinAndKey failed", re); throw re; } return rfl; } @SuppressWarnings("unchecked") public RequestForLicense findByDevIdProdId(String deviceId, Long prodId, String requestorIp) { RequestForLicense rfl = null; try { String qs = "from RequestForLicense as rfl where rfl.deviceId= :deviceId and rfl.product.id= :prodId and " + "rfl.requestorIp= :requestorIp and rfl.numDeviceRequests > 0 and rfl.product.licLifeInDays < 365"; Query query = getSession().createQuery(qs); query.setParameter("deviceId", deviceId); query.setParameter("prodId", prodId); query.setParameter("requestorIp", requestorIp); query.setMaxResults(1); List<RequestForLicense> rfls = query.list(); if (rfls != null && rfls.size() > 0) rfl = rfls.get(0); } catch (RuntimeException re) { log.error("findByDevIdProdId failed", re); throw re; } return rfl; } @SuppressWarnings("unchecked") public List<RequestForLicense> findByExample(RequestForLicense instance) { log.debug("finding RequestForLicense instance by example"); try { List<RequestForLicense> results = getHibernateTemplate().findByExample(instance); log.debug("find by example successful, result size: " + results.size()); return results; } catch (RuntimeException re) { log.error("find by example failed", re); throw re; } } @SuppressWarnings("unchecked") public List<RequestForLicense> findByProperty(String propertyName, Object value) { log.debug("finding RequestForLicense instance with property: " + propertyName + ", value: " + value); try { String queryString = "from RequestForLicense as model where model." + propertyName + "= ?"; return getHibernateTemplate().find(queryString, value); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } } public List<RequestForLicense> findByRequestor(Object requestor) { return findByProperty(REQUESTOR, requestor); } public List<RequestForLicense> findByResponse(Object response) { return findByProperty(RESPONSE, response); } public List<RequestForLicense> findByNumRequested(Object numRequested) { return findByProperty(NUM_REQUESTED, numRequested); } public List<RequestForLicense> findByNumReturned(Object numReturned) { return findByProperty(NUM_RETURNED, numReturned); } public List<RequestForLicense> findByNumOverDraft(Object numOverDraft) { return findByProperty(NUM_OVER_DRAFT, numOverDraft); } public List<RequestForLicense> findByLicKeys(Object licKeys) { return findByProperty(LIC_KEYS, licKeys); } public List<RequestForLicense> findByRequestorIp(Object requestorIp) { return findByProperty(REQUESTOR_IP, requestorIp); } public List<RequestForLicense> findByNumDeviceRequests(Object numDeviceRequests) { return findByProperty(NUM_DEVICE_REQUESTS, numDeviceRequests); } public List<RequestForLicense> findByDeviceId(Object deviceId) { return findByProperty(DEVICE_ID, deviceId); } public List<RequestForLicense> findByIsvProductId(Object isvProductId) { return findByProperty(ISV_PRODUCT_ID, isvProductId); } public List<RequestForLicense> findByReqOrderId(Object reqOrderId) { return findByProperty(REQ_ORDER_ID, reqOrderId); } public List<RequestForLicense> findByReqRefId(Object reqRefId) { return findByProperty(REQ_REF_ID, reqRefId); } public List<RequestForLicense> findByUserFirstName(Object userFirstName) { return findByProperty(USER_FIRST_NAME, userFirstName); } public List<RequestForLicense> findByUserLastName(Object userLastName) { return findByProperty(USER_LAST_NAME, userLastName); } public List<RequestForLicense> findByUserEmail(Object userEmail) { return findByProperty(USER_EMAIL, userEmail); } public List<RequestForLicense> findByUserPhone(Object userPhone) { return findByProperty(USER_PHONE, userPhone); } public List<RequestForLicense> findByUserCountry(Object userCountry) { return findByProperty(USER_COUNTRY, userCountry); } public List<RequestForLicense> findByUserCountryCode(Object userCountryCode) { return findByProperty(USER_COUNTRY_CODE, userCountryCode); } public List<RequestForLicense> findByUserState(Object userState) { return findByProperty(USER_STATE, userState); } public List<RequestForLicense> findByUserCity(Object userCity) { return findByProperty(USER_CITY, userCity); } public List<RequestForLicense> findByUserZip(Object userZip) { return findByProperty(USER_ZIP, userZip); } public List<RequestForLicense> findByReqSignature(Object reqSignature) { return findByProperty(REQ_SIGNATURE, reqSignature); } public List<RequestForLicense> findByReqProduct(Object reqProduct) { return findByProperty(REQ_PRODUCT, reqProduct); } public List<RequestForLicense> findByReqProductVersion(Object reqProductVersion) { return findByProperty(REQ_PRODUCT_VERSION, reqProductVersion); } public List<RequestForLicense> findBySpecialUserId(Object specialUserId) { return findByProperty(SPECIAL_USER_ID, specialUserId); } public List<RequestForLicense> findBySharedSecret(Object sharedSecret) { return findByProperty(SHARED_SECRET, sharedSecret); } public List<RequestForLicense> findByPurchasePriceUsd(Object purchasePriceUsd) { return findByProperty(PURCHASE_PRICE_USD, purchasePriceUsd); } public List<RequestForLicense> findByPartnerId(Object partnerId) { return findByProperty(PARTNER_ID, partnerId); } public List<RequestForLicense> findBySaleCurrency(Object saleCurrency) { return findByProperty(SALE_CURRENCY, saleCurrency); } public List<RequestForLicense> findByStatus(Object status) { return findByProperty(STATUS, status); } public List<RequestForLicense> findByActivationCode(Object activationCode) { return findByProperty(ACTIVATION_CODE, activationCode); } public List<RequestForLicense> findByPromotionCode(Object promotionCode) { return findByProperty(PROMOTION_CODE, promotionCode); } public List<RequestForLicense> findByOrderDate(Object orderDate) { return findByProperty(ORDER_DATE, orderDate); } public List<RequestForLicense> findByChannel(Object channel) { return findByProperty(CHANNEL, channel); } public List<RequestForLicense> findByAffiliateId(Object affiliateId) { return findByProperty(AFFILIATE_ID, affiliateId); } public List<RequestForLicense> findByAction(Object action) { return findByProperty(ACTION, action); } public List<RequestForLicense> findBySubscriptionId(Object subscriptionId) { return findByProperty(SUBSCRIPTION_ID, subscriptionId); } public List<RequestForLicense> findBySubscriptionExpirationAte(Object subscriptionExpirationAte) { return findByProperty(SUBSCRIPTION_EXPIRATION_ATE, subscriptionExpirationAte); } public List<RequestForLicense> findByCreatedBy(Object createdBy) { return findByProperty(CREATED_BY, createdBy); } public List<RequestForLicense> findByModifiedBy(Object modifiedBy) { return findByProperty(MODIFIED_BY, modifiedBy); } @SuppressWarnings("unchecked") public List<RequestForLicense> findAll() { log.debug("finding all RequestForLicense instances"); try { String queryString = "from RequestForLicense"; return getHibernateTemplate().find(queryString); } catch (RuntimeException re) { log.error("find all failed", re); throw re; } } public RequestForLicense merge(RequestForLicense detachedInstance) { log.debug("merging RequestForLicense instance"); try { RequestForLicense result = getHibernateTemplate().merge(detachedInstance); log.debug("merge successful"); return result; } catch (RuntimeException re) { log.error("merge failed", re); throw re; } } public void attachDirty(RequestForLicense instance) { log.debug("attaching dirty RequestForLicense instance"); try { getHibernateTemplate().saveOrUpdate(instance); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } } public void attachClean(RequestForLicense instance) { log.debug("attaching clean RequestForLicense instance"); try { getHibernateTemplate().lock(instance, LockMode.NONE); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } } public static RequestForLicenseDAO getFromApplicationContext(ApplicationContext ctx) { return (RequestForLicenseDAO) ctx.getBean("RequestForLicenseDAO"); } }