List of usage examples for org.hibernate.type LongType LongType
public LongType()
From source file:com.viettel.logistic.wms.dao.StockTransSerialDAO.java
License:Open Source License
public List<StockTransSerial> getListStockTransSerialBySerialStrip(StockTransSerialDTO stockTransSerialDTO) { List<StockTransSerial> lst = new ArrayList(); StringBuffer sql = new StringBuffer(); List lstParams = new ArrayList(); sql.append("SELECT a.stock_trans_serial_id stockTransSerialId,"); sql.append(" a.stock_trans_id stockTransId,"); sql.append(" a.stock_trans_detail_id stockTransDetailId,"); sql.append(" a.stock_trans_date stockTransDate,"); sql.append(" a.goods_id goodsId,"); sql.append(" a.goods_code goodsCode,"); sql.append(" a.goods_name goodsName,"); sql.append(" a.goods_state goodsState,"); sql.append(" a.goods_unit_type goodsUnitType,"); sql.append(" a.goods_unit_type_name goodsUnitTypeName,"); sql.append(" a.from_serial fromSerial,"); sql.append(" a.to_serial toserial,"); sql.append(" a.amount_order amountOrder,"); sql.append(" a.amount_real amountReal,"); sql.append(" a.bincode bincode,"); sql.append(" a.barcode barcode,"); sql.append(" a.cell_code cellCode,"); sql.append(" a.notes notes,"); sql.append(" a.create_datetime createDatetime,"); sql.append(" a.add_infor addInfor"); sql.append(" FROM stock_trans_serial a"); sql.append(" WHERE 1 = 1 AND"); sql.append(" goods_id = ?"); sql.append(" AND"); sql.append(" from_serial <= ?"); sql.append(" AND"); sql.append(" to_serial >= ? "); sql.append(" AND stock_trans_date >= TO_DATE(?,'dd/mm/yyyy')"); sql.append(" AND stock_trans_date <= TO_DATE(?,'dd/mm/yyyy') + 1"); sql.append(" Order by stock_trans_date ASC"); ////from w ww .j a va2 s.co m lstParams.add(stockTransSerialDTO.getGoodsId()); lstParams.add(stockTransSerialDTO.getToSerial()); lstParams.add(stockTransSerialDTO.getFromSerial()); lstParams.add(stockTransSerialDTO.getFromDateSearch()); lstParams.add(stockTransSerialDTO.getToDateSearch()); // SQLQuery query = getSession().createSQLQuery(sql.toString()); query.setResultTransformer(Transformers.aliasToBean(StockTransSerial.class)); // query.addScalar("stockTransSerialId", new LongType()); query.addScalar("stockTransId", new LongType()); query.addScalar("stockTransDetailId", new LongType()); query.addScalar("stockTransDate", new DateType()); query.addScalar("goodsId", new LongType()); query.addScalar("goodsCode", new StringType()); query.addScalar("goodsName", new StringType()); query.addScalar("goodsState", new StringType()); query.addScalar("goodsUnitType", new StringType()); query.addScalar("goodsUnitTypeName", new StringType()); query.addScalar("fromSerial", new StringType()); query.addScalar("toSerial", new StringType()); query.addScalar("amountOrder", new LongType()); query.addScalar("amountReal", new LongType()); query.addScalar("bincode", new StringType()); query.addScalar("barcode", new StringType()); query.addScalar("cellCode", new StringType()); query.addScalar("notes", new StringType()); query.addScalar("createDatetime", new DateType()); query.addScalar("addInfor", new StringType()); // for (int i = 0; i < lstParams.size(); i++) { query.setParameter(i, lstParams.get(i)); } lst = query.list(); return lst; }
From source file:de.codesourcery.eve.skills.db.dao.InventoryTypeDAO.java
License:Apache License
@Override public List<InventoryType> getInventoryTypes(final MarketGroup group) { if (group == null) { throw new IllegalArgumentException("group must not be NULL"); }/* w ww.j av a2 s .c o m*/ final List<InventoryType> cached = typeByMarketGroupID.get(group.getId()); if (cached != null) { return new ArrayList<>(cached); } return execute(new HibernateCallback<List<InventoryType>>() { @Override public List<InventoryType> doInSession(Session session) { final SQLQuery query = session .createSQLQuery("SELECT typeID FROM invTypes WHERE marketGroupID = :marketGroupId"); query.setParameter("marketGroupId", group.getId()); query.addScalar("typeID", new LongType()); final List<InventoryType> result = getInventoryTypesByIDs(query.list()); typeByMarketGroupID.putIfAbsent(group.getId(), new ArrayList<>(result)); return result; } }); }
From source file:de.codesourcery.eve.skills.db.dao.InventoryTypeDAO.java
License:Apache License
@Override public List<InventoryType> getInventoryTypesWithBlueprints(final MarketGroup group) { return execute(new HibernateCallback<List<InventoryType>>() { @Override/*from w ww .ja va2s . c o m*/ public List<InventoryType> doInSession(Session session) { final SQLQuery query = session .createSQLQuery("SELECT i.typeID FROM invTypes i , invBlueprintTypes bp WHERE " + "i.marketGroupID = :marketGroupId AND bp.productTypeID = i.typeID"); query.setParameter("marketGroupId", group.getId()); query.addScalar("typeID", new LongType()); return getInventoryTypesByIDs(query.list()); } }); }
From source file:gov.nih.nci.security.authorization.instancelevel.InstanceLevelSecurityHelper.java
License:BSD License
/** * This method injects the security filters which are created for this application. It retrieves a list of all the filters which have * been defined for this application from the CSM Database. Now for each filter in the list, it creates a new FilterDefinition object. * It then retrieves the Persistent Class from the passed Configuration Object using the class name for which the filter is defined. * It then adds the filter to the persistent class by setting the filtering query. * @param authorizationManager The CSM AuthorizationManager instance for this application * @param configuration The Hibernate Configuration initialized for this application * // w ww .j a v a 2s .c o m */ public static void addFiltersForGroups(AuthorizationManager authorizationManager, Configuration configuration) { boolean needsOptimisation = false; Properties props = configuration.getProperties(); //If using InstanceLevel Query Performance Enhancements of 4.2, then no need to optimize query for MySQL Db. if (!isExistActiveMappingElement(authorizationManager)) needsOptimisation = isMySQLDatabase(props, true); // Inject CSM Filters for Group List list = retriveAllCsmFilterClause(authorizationManager); Iterator iterator = list.iterator(); while (iterator.hasNext()) { HashMap parameters = new HashMap(); parameters.put("GROUP_NAMES", new StringType()); parameters.put("APPLICATION_ID", new LongType()); FilterClause filterClause = (FilterClause) iterator.next(); FilterDefinition filterDefinition = new FilterDefinition( filterClause.getClassName().substring(filterClause.getClassName().lastIndexOf('.') + 1) + filterClause.getId(), "", parameters); configuration.addFilterDefinition(filterDefinition); PersistentClass persistentClass = configuration.getClassMapping(filterClause.getClassName()); persistentClass.addFilter( filterClause.getClassName().substring(filterClause.getClassName().lastIndexOf('.') + 1) + filterClause.getId(), optimiseFilterQuery(needsOptimisation, filterClause.getGeneratedSQLForGroup())); } }
From source file:gov.nih.nci.security.authorization.instancelevel.InstanceLevelSecurityHelper.java
License:BSD License
/** * This method injects the security filters which are created for this application. It retrieves a list of all the filters which have * been defined for this application from the CSM Database. Now for each filter in the list, it creates a new FilterDefinition object. * //from ww w. j a v a 2 s . com * @param authorizationManager The CSM AuthorizationManager instance for this application * @param List<FilterDefinition> The Hibernate FilterDefinition List. */ public static List<FilterDefinition> getFiltersForGroups(AuthorizationManager authorizationManager) throws CSException { Properties props = new Properties(); ApplicationContext ac = authorizationManager.getApplicationContext(); props.setProperty("hibernate.connection.url", ac.getDatabaseURL()); props.setProperty("hibernate.connection.username", ac.getDatabaseUserName()); props.setProperty("hibernate.connection.password", ac.getDatabasePassword()); props.setProperty("hibernate.connection.driver", ac.getDatabaseDriver()); props.setProperty("hibernate.dialect", ac.getDatabaseDialect()); boolean needsOptimisation = false; if (!isExistActiveMappingElement(authorizationManager)) needsOptimisation = isMySQLDatabase(props, false); List<FilterDefinition> filterDefinitionList = new ArrayList<FilterDefinition>(); List list = retriveAllCsmFilterClause(authorizationManager); Iterator iterator = list.iterator(); while (iterator.hasNext()) { HashMap parameters = new HashMap(); parameters.put("GROUP_NAMES", new StringType()); parameters.put("APPLICATION_ID", new LongType()); FilterClause filterClause = (FilterClause) iterator.next(); FilterDefinition filterDefinition = new FilterDefinition( filterClause.getClassName().substring(filterClause.getClassName().lastIndexOf('.') + 1) + filterClause.getId(), optimiseFilterQuery(needsOptimisation, filterClause.getGeneratedSQLForGroup()), parameters); if (filterDefinition != null) filterDefinitionList.add(filterDefinition); } return filterDefinitionList; }
From source file:gov.nih.nci.security.authorization.instancelevel.InstanceLevelSecurityHelper.java
License:BSD License
/** * This method injects the security filters which are created for this application. It retrieves a list of all the filters which have * been defined for this application from the CSM Database. Now for each filter in the list, it creates a new FilterDefinition object. * It then retrieves the Persistent Class from the passed Configuration Object using the class name for which the filter is defined. * It then adds the filter to the persistent class by setting the filtering query. * @param authorizationManager The CSM AuthorizationManager instance for this application * @param configuration The Hibernate Configuration initialized for this application *///from ww w. j a v a2s. c o m public static void addFilters(AuthorizationManager authorizationManager, Configuration configuration) { boolean needsOptimisation = false; Properties props = configuration.getProperties(); if (!isExistActiveMappingElement(authorizationManager)) needsOptimisation = isMySQLDatabase(props, true); // Inject CSM defined Filters List list = retriveAllCsmFilterClause(authorizationManager); Iterator iterator = list.iterator(); while (iterator.hasNext()) { HashMap parameters = new HashMap(); parameters.put("USER_NAME", new StringType()); parameters.put("APPLICATION_ID", new LongType()); FilterClause filterClause = (FilterClause) iterator.next(); FilterDefinition filterDefinition = new FilterDefinition( filterClause.getClassName().substring(filterClause.getClassName().lastIndexOf('.') + 1) + filterClause.getId(), "", parameters); configuration.addFilterDefinition(filterDefinition); PersistentClass persistentClass = configuration.getClassMapping(filterClause.getClassName()); persistentClass.addFilter( filterClause.getClassName().substring(filterClause.getClassName().lastIndexOf('.') + 1) + filterClause.getId(), optimiseFilterQuery(needsOptimisation, filterClause.getGeneratedSQLForUser())); } }
From source file:gov.nih.nci.security.authorization.instancelevel.InstanceLevelSecurityHelper.java
License:BSD License
/** * This method injects the security filters which are created for this application. It retrieves a list of all the filters which have * been defined for this application from the CSM Database. Now for each filter in the list, it creates a new FilterDefinition object. * /*from ww w . j av a 2 s . c om*/ * * @param authorizationManager The CSM AuthorizationManager instance for this application * @param List<FilterDefinition> The Hibernate FilterDefinition List. */ public static List<FilterDefinition> getFiltersForUser(AuthorizationManager authorizationManager) throws CSException { Properties props = new Properties(); ApplicationContext ac = authorizationManager.getApplicationContext(); props.setProperty("hibernate.connection.url", ac.getDatabaseURL()); props.setProperty("hibernate.connection.username", ac.getDatabaseUserName()); props.setProperty("hibernate.connection.password", ac.getDatabasePassword()); props.setProperty("hibernate.connection.driver", ac.getDatabaseDriver()); props.setProperty("hibernate.dialect", ac.getDatabaseDialect()); boolean needsOptimisation = false; if (!isExistActiveMappingElement(authorizationManager)) needsOptimisation = isMySQLDatabase(props, false); List<FilterDefinition> filterDefinitionList = new ArrayList<FilterDefinition>(); List list = retriveAllCsmFilterClause(authorizationManager); Iterator iterator = list.iterator(); while (iterator.hasNext()) { HashMap parameters = new HashMap(); parameters.put("USER_NAME", new StringType()); parameters.put("APPLICATION_ID", new LongType()); FilterClause filterClause = (FilterClause) iterator.next(); FilterDefinition filterDefinition = new FilterDefinition( filterClause.getClassName().substring(filterClause.getClassName().lastIndexOf('.') + 1) + filterClause.getId(), optimiseFilterQuery(needsOptimisation, filterClause.getGeneratedSQLForUser()), parameters); if (filterDefinition != null) filterDefinitionList.add(filterDefinition); } return filterDefinitionList; }
From source file:org.jpos.gl.GLSession.java
License:Open Source License
private void addRules(Map<String, Object> ruleMap, Journal journal, List acctHierarchy, int offset) throws HibernateException, GLException { Query q = session.createQuery( "from org.jpos.gl.RuleInfo where journal=:journal and account in (:accts) order by id"); q.setParameter("journal", journal); q.setParameterList("accts", acctHierarchy, new LongType()); q.setCacheable(true);/* w w w . ja v a 2 s . com*/ q.setCacheRegion("rules"); Iterator iter = q.iterate(); while (iter.hasNext()) { RuleInfo ri = (RuleInfo) iter.next(); RuleEntry k = new RuleEntry(ri, ri.getAccount()); RuleEntry re = (RuleEntry) ruleMap.get(k.getKey()); if (re == null) ruleMap.put(k.getKey(), re = k); re.addOffset(offset); } }
From source file:org.kuali.rice.core.framework.persistence.jpa.RiceNumericStringSequenceStyleGenerator.java
License:Educational Community License
/** * Performs the same configuration operations as those of the superclass, except that the provided Type will be replaced by Hibernate's LongType instead. * /*w ww .java 2 s.c o m*/ * TODO: Should we add a configuration parameter for allowing users to specify a different supported Hibernate numeric Type if desired? * * @see org.hibernate.id.enhanced.SequenceStyleGenerator#configure(org.hibernate.type.Type, java.util.Properties, org.hibernate.dialect.Dialect) */ @Override public void configure(Type type, Properties params, Dialect dialect) throws MappingException { super.configure(new LongType(), params, dialect); }
From source file:org.sakaiproject.attendance.dao.impl.AttendanceDaoImpl.java
License:Educational Community License
private Object getByIDHelper(final long id, final String queryString) { if (log.isDebugEnabled()) { log.debug("getByIDHelper() id: '" + String.valueOf(id) + "' String: " + queryString); }//from ww w. j ava2 s .com try { HibernateCallback hcb = new HibernateCallback() { @Override public Object doInHibernate(Session session) throws HibernateException { Query q = session.getNamedQuery(queryString); q.setParameter(ID, id, new LongType()); q.setMaxResults(1); return q.uniqueResult(); } }; return getHibernateTemplate().execute(hcb); } catch (DataAccessException e) { log.error("getByIDHelper for " + queryString + " failed", e); return null; } }