List of usage examples for org.hibernate.type StandardBasicTypes INTEGER
IntegerType INTEGER
To view the source code for org.hibernate.type StandardBasicTypes INTEGER.
Click Source Link
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.resource.ResourceRepositoryHibernate.java
License:Open Source License
@Override public Integer getSubscriptionCountForGooruOid(String contentGooruOid) { Query query = getSession().createSQLQuery(COUNT_SUBSCRIPTION_FOR_GOORUOID) .addScalar("totalCount", StandardBasicTypes.INTEGER).setParameter("gooruOid", contentGooruOid); addOrgAuthParameters(query);//w w w. j av a2s . c om List<Integer> subscriptionCounts = query.list(); if ((subscriptionCounts != null) && (subscriptionCounts.size() > 0)) { return subscriptionCounts.get(0); } else { return new Integer(0); } }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.session.SessionRepositoryHibernate.java
License:Open Source License
@Override public Map<String, Object> getQuizSummary(String sessionId, Integer trySequence, String questionType, Long quizContentId) {/*from w w w . j a v a 2 s . c o m*/ Session session = getSession(); String sql = "select count(aq.question_id) as attemptedQuestionCount, " + "sum(case sit.attempt_item_try_status when 'correct' then 1 else 0 end ) as correctAnswerCount, " + "sum(case sit.attempt_item_try_status when 'wrong' then 1 else 0 end ) as wrongAnswerCount " + "from session s " + "inner join session_item si on (si.session_id = s.session_id) " + "inner join session_item_attempt_try sit on (sit.session_item_id = si.session_item_id) " + "inner join assessment_question aq on (aq.question_id = si.resource_id) " + "where si.session_id = :sessionId and try_sequence = :trySequence and s.status = 'archive' " + "and aq.type in (:questionType)"; if (quizContentId != null && quizContentId != 0) { sql += " and s.collection_id = :quizId"; } Query query = session.createSQLQuery(sql).addScalar("attemptedQuestionCount", StandardBasicTypes.INTEGER) .addScalar("correctAnswerCount", StandardBasicTypes.INTEGER) .addScalar("wrongAnswerCount", StandardBasicTypes.INTEGER).setParameter("sessionId", sessionId) .setParameter("trySequence", trySequence).setParameter("questionType", questionType); if (quizContentId != null && quizContentId != 0) { query.setParameter("quizId", quizContentId); } return getQuizSummary((Object[]) query.list().get(0)); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.user.UserRepositoryHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") public String checkUserStatus(String email, String code) { String userStatus = null;//from w w w . j a v a2 s . co m List<Integer> results = getSession().createSQLQuery(FIND_REGISTERED_USER) .addScalar(TOTAL_COUNT, StandardBasicTypes.INTEGER).setParameter("emailId", email).list(); int count = (results.size() > 0) ? results.get(0) : 0; Calendar currenttime = Calendar.getInstance(); java.sql.Date sqldate = new java.sql.Date((currenttime.getTime()).getTime()); if (count > 0) { userStatus = "registered"; } else { results = getSession().createSQLQuery(CHECK_CODE).addScalar(TOTAL_COUNT, StandardBasicTypes.INTEGER) .setParameter("code", code.trim()).setParameter("dateOfExpiry", sqldate.toString()).list(); Integer codeCount = (results.size() > 0) ? results.get(0) : 0; if ((codeCount != null) && (codeCount.intValue() > 0)) { userStatus = "valid_code"; } } return (userStatus == null) ? "unknown" : userStatus; }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.user.UserRepositoryHibernate.java
License:Open Source License
@Override public Integer getInactiveUsersCount() { Query query = getSession().createSQLQuery(INACTIVE_USER_COUNT_FOR_LAST_TWO_WEEKS).addScalar("count", StandardBasicTypes.INTEGER); return (Integer) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.user.UserRepositoryHibernate.java
License:Open Source License
@Override public Integer getUserTokenCount(String gooruUid) { String sql = "select count(1) as count from user_token token where token.user_uid='" + gooruUid + "'"; Query query = getSession().createSQLQuery(sql).addScalar("count", StandardBasicTypes.INTEGER); return (Integer) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.user.UserRepositoryHibernate.java
License:Open Source License
@Override public Integer getUserBirthdayCount() { Query query = getSession().createSQLQuery(FETCH_USERS_BY_BIRTHDAY_COUNT).addScalar("count", StandardBasicTypes.INTEGER); return (Integer) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.user.UserRepositoryHibernate.java
License:Open Source License
@Override public Integer getChildUserBirthdayCount() { Query query = getSession().createSQLQuery(FETCH_CHILD_USERS_BY_BIRTHDAY_COUNT).addScalar("count", StandardBasicTypes.INTEGER); return (Integer) query.list().get(0); }
From source file:org.goobi.production.flow.statistics.hibernate.StatQuestProduction.java
License:Open Source License
/** * List objects here need to extend BaseDTO. * * <p>// www . ja va2s. c om * (non-Javadoc) * </p> * * @see org.goobi.production.flow.statistics.IStatisticalQuestion#getDataTables( * List) */ @Override public List<DataTable> getDataTables(List<? extends BaseDTO> dataSource) { // contains an intger representing "reihenfolge" in schritte, as defined // for this request // if not defined it will trigger a fall back on a different way of // retrieving the statistical data Integer exactStepDone = null; String stepname = null; List<DataTable> allTables = new ArrayList<>(); // gathering some information from the filter passed by dataSource // exactStepDone is very important ... //TODO; find way to replace it /*try { exactStepDone = originalFilter.stepDone(); } catch (UnsupportedOperationException e1) { logger.error(e1); } try { stepname = originalFilter.stepDoneName(); } catch (UnsupportedOperationException e1) { logger.error(e1); }*/ // we have to build a query from scratch by reading the ID's List<Integer> idList = getIds(dataSource); if (idList == null || idList.size() == 0) { return null; } String natSQL = ""; // adding time restrictions if (stepname == null) { natSQL = new ImprovedSQLProduction(this.timeFilterFrom, this.timeFilterTo, this.timeGrouping, idList) .getSQL(exactStepDone); } else { natSQL = new ImprovedSQLProduction(this.timeFilterFrom, this.timeFilterTo, this.timeGrouping, idList) .getSQL(stepname); } Session session = Helper.getHibernateSession(); SQLQuery query = session.createSQLQuery(natSQL); // needs to be there otherwise an exception is thrown query.addScalar("volumes", StandardBasicTypes.INTEGER); query.addScalar("pages", StandardBasicTypes.INTEGER); query.addScalar("intervall", StandardBasicTypes.STRING); @SuppressWarnings("rawtypes") List list = query.list(); StringBuilder title = new StringBuilder(StatisticsMode.PRODUCTION.getTitle()); title.append(" ("); title.append(this.cu.getTitle()); if (stepname == null || stepname.equals("")) { title.append(")"); } else { title.append(", "); title.append(stepname); title.append(" )"); } // building table for the Table DataTable dtbl = new DataTable(title.toString()); // building a second table for the chart DataTable dtblChart = new DataTable(title.toString()); // DataRow dataRowChart; DataRow dataRow; // each data row comes out as an Array of Objects // the only way to extract the data is by knowing // in which order they come out for (Object obj : list) { dataRowChart = new DataRow(null); dataRow = new DataRow(null); Object[] objArr = (Object[]) obj; try { // getting localized time group unit // String identifier = timeGrouping.getTitle(); // setting row name with localized time group and the date/time // extraction based on the group dataRowChart.setName(new Converter(objArr[2]).getString() + ""); dataRow.setName(new Converter(objArr[2]).getString() + ""); // dataRow.setName(new Converter(objArr[2]).getString()); // building up row depending on requested output having // different fields switch (this.cu) { case volumesAndPages: { dataRowChart.addValue(CalculationUnit.volumes.getTitle(), (new Converter(objArr[0]).getDouble())); dataRowChart.addValue(CalculationUnit.pages.getTitle() + " (*100)", (new Converter(objArr[1]).getDouble()) / 100); dataRow.addValue(CalculationUnit.volumes.getTitle(), (new Converter(objArr[0]).getDouble())); dataRow.addValue(CalculationUnit.pages.getTitle(), (new Converter(objArr[1]).getDouble())); } break; case volumes: { dataRowChart.addValue(CalculationUnit.volumes.getTitle(), (new Converter(objArr[0]).getDouble())); dataRow.addValue(CalculationUnit.volumes.getTitle(), (new Converter(objArr[0]).getDouble())); } break; case pages: { dataRowChart.addValue(CalculationUnit.pages.getTitle(), (new Converter(objArr[1]).getDouble())); dataRow.addValue(CalculationUnit.pages.getTitle(), (new Converter(objArr[1]).getDouble())); } break; } // fall back, if conversion triggers an exception } catch (Exception e) { dataRowChart.addValue(e.getMessage(), 0.0); dataRow.addValue(e.getMessage(), 0.0); } // finally adding dataRow to DataTable and fetching next row // adding the extra table dtblChart.addDataRow(dataRowChart); dtbl.addDataRow(dataRow); } // a list of DataTables is expected as return Object, even if there is // only one // Data Table as it is here in this implementation dtblChart.setUnitLabel(Helper.getTranslation(this.timeGrouping.getSingularTitle())); dtbl.setUnitLabel(Helper.getTranslation(this.timeGrouping.getSingularTitle())); dtblChart.setShowableInTable(false); dtbl.setShowableInChart(false); allTables.add(dtblChart); allTables.add(dtbl); return allTables; }
From source file:org.jadira.usertype.spi.shared.AbstractIntegerColumnMapper.java
License:Apache License
public final IntegerType getHibernateType() { return StandardBasicTypes.INTEGER; }
From source file:org.jboss.as.quickstart.hibernate4.util.vertica.VerticaDialect6.java
License:Open Source License
protected void registerFunctions() { registerFunction("abs", new StandardSQLFunction("abs")); registerFunction("sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER)); registerFunction("acos", new StandardSQLFunction("acos", StandardBasicTypes.DOUBLE)); registerFunction("asin", new StandardSQLFunction("asin", StandardBasicTypes.DOUBLE)); registerFunction("atan", new StandardSQLFunction("atan", StandardBasicTypes.DOUBLE)); registerFunction("cos", new StandardSQLFunction("cos", StandardBasicTypes.DOUBLE)); registerFunction("exp", new StandardSQLFunction("exp", StandardBasicTypes.DOUBLE)); registerFunction("ln", new StandardSQLFunction("ln", StandardBasicTypes.DOUBLE)); registerFunction("sin", new StandardSQLFunction("sin", StandardBasicTypes.DOUBLE)); registerFunction("stddev", new StandardSQLFunction("stddev", StandardBasicTypes.DOUBLE)); registerFunction("sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE)); registerFunction("tan", new StandardSQLFunction("tan", StandardBasicTypes.DOUBLE)); registerFunction("variance", new StandardSQLFunction("variance", StandardBasicTypes.DOUBLE)); registerFunction("round", new StandardSQLFunction("round")); registerFunction("trunc", new StandardSQLFunction("trunc")); registerFunction("ceil", new StandardSQLFunction("ceil")); registerFunction("floor", new StandardSQLFunction("floor")); registerFunction("chr", new StandardSQLFunction("chr", StandardBasicTypes.CHARACTER)); registerFunction("initcap", new StandardSQLFunction("initcap")); registerFunction("lower", new StandardSQLFunction("lower")); registerFunction("ltrim", new StandardSQLFunction("ltrim")); registerFunction("rtrim", new StandardSQLFunction("rtrim")); registerFunction("upper", new StandardSQLFunction("upper")); registerFunction("ascii", new StandardSQLFunction("ascii", StandardBasicTypes.INTEGER)); registerFunction("to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING)); registerFunction("to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP)); registerFunction("current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false)); registerFunction("current_time", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIME, false)); registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false)); registerFunction("last_day", new StandardSQLFunction("last_day", StandardBasicTypes.DATE)); registerFunction("sysdate", new NoArgSQLFunction("sysdate", StandardBasicTypes.DATE, false)); registerFunction("user", new NoArgSQLFunction("user", StandardBasicTypes.STRING, false)); // Multi-param string dialect functions... registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "")); registerFunction("instr", new StandardSQLFunction("instr", StandardBasicTypes.INTEGER)); registerFunction("instrb", new StandardSQLFunction("instrb", StandardBasicTypes.INTEGER)); registerFunction("lpad", new StandardSQLFunction("lpad", StandardBasicTypes.STRING)); registerFunction("replace", new StandardSQLFunction("replace", StandardBasicTypes.STRING)); registerFunction("rpad", new StandardSQLFunction("rpad", StandardBasicTypes.STRING)); registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING)); registerFunction("substrb", new StandardSQLFunction("substrb", StandardBasicTypes.STRING)); registerFunction("translate", new StandardSQLFunction("translate", StandardBasicTypes.STRING)); registerFunction("substring", new StandardSQLFunction("substr", StandardBasicTypes.STRING)); registerFunction("bit_length", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "vsize(?1)*8")); registerFunction("coalesce", new NvlFunction()); // Multi-param numeric dialect functions... registerFunction("atan2", new StandardSQLFunction("atan2", StandardBasicTypes.FLOAT)); registerFunction("log", new StandardSQLFunction("log", StandardBasicTypes.INTEGER)); registerFunction("mod", new StandardSQLFunction("mod", StandardBasicTypes.INTEGER)); registerFunction("nvl", new StandardSQLFunction("nvl")); registerFunction("nvl2", new StandardSQLFunction("nvl2")); registerFunction("power", new StandardSQLFunction("power", StandardBasicTypes.FLOAT)); // Multi-param date dialect functions... registerFunction("add_months", new StandardSQLFunction("add_months", StandardBasicTypes.DATE)); registerFunction("months_between", new StandardSQLFunction("months_between", StandardBasicTypes.FLOAT)); registerFunction("next_day", new StandardSQLFunction("next_day", StandardBasicTypes.DATE)); }