List of usage examples for org.springframework.jdbc.core.namedparam MapSqlParameterSource MapSqlParameterSource
public MapSqlParameterSource(String paramName, @Nullable Object value)
From source file:alfio.manager.system.DataMigrator.java
private void fillDefaultOptions() { transactionTemplate.execute(ts -> { int count = jdbc.queryForObject("select count(*) from configuration where c_key = :key", new MapSqlParameterSource("key", ConfigurationKeys.GOOGLE_ANALYTICS_ANONYMOUS_MODE.getValue()), Integer.class); if (count == 0) { configurationRepository.insert(ConfigurationKeys.GOOGLE_ANALYTICS_ANONYMOUS_MODE.getValue(), "true", ConfigurationKeys.GOOGLE_ANALYTICS_ANONYMOUS_MODE.getDescription()); }// w w w . ja va2 s. com return null; }); }
From source file:com.daugherty.e2c.persistence.data.jdbc.JdbcSupplierDao.java
@Override public List<Supplier> loadLatestBySupplierIds(List<Long> ids, Locale locale) { List<Supplier> suppliers = Lists.newArrayList(); HashSet<Long> uniqueIds = Sets.newHashSet(ids); LOGGER.debug("Getting Supplier from the database by supplier ids " + uniqueIds); for (List<Long> partitionedIds : Lists.partition(Lists.newArrayList(uniqueIds), 1000)) { String sql = getSql("/supplier/getLatestBySupplierIds.sql"); SqlParameterSource parameterSource = new MapSqlParameterSource("supplierIds", partitionedIds) .addValue("language", locale.getLanguage()); suppliers.addAll(jdbcTemplate.query(sql, parameterSource, new SupplierResultSetExtractor())); }//from w w w. ja va 2 s.c o m return suppliers; }
From source file:tds.assessment.repositories.impl.AssessmentWindowQueryRepositoryImpl.java
@Override public List<AssessmentWindow> findCurrentAssessmentFormWindows(final String clientName, final String assessmentId, final int shiftWindowStart, final int shiftWindowEnd, final int shiftFormStart, final int shiftFormEnd) { final MapSqlParameterSource parameters = new MapSqlParameterSource("clientName", clientName) .addValue("assessmentId", assessmentId).addValue("shiftWindowStart", shiftWindowStart) .addValue("shiftWindowEnd", shiftWindowEnd).addValue("shiftFormStart", shiftFormStart) .addValue("shiftFormEnd", shiftFormEnd).addValue("sessionType", ONLINE_SESSION_TYPE); //NOTE - SessionType is always 0 for the online application String SQL = "SELECT\n" + " windowID, \n" + " W.numopps AS windowMax, \n" + " M.maxopps AS modeMax, \n" + " CASE WHEN W.startDate IS NULL THEN UTC_TIMESTAMP() ELSE (W.startDate + INTERVAL :shiftWindowStart DAY) END AS startDate,\n" + " CASE WHEN W.endDate IS NULL THEN UTC_TIMESTAMP() ELSE (W.endDate + INTERVAL :shiftWindowEnd DAY) END AS endDate,\n" + " CASE WHEN F.startDate IS NULL THEN UTC_TIMESTAMP() ELSE ( F.startdate + INTERVAL :shiftFormStart DAY) END AS formStart,\n" + " CASE WHEN F.enddate IS NULL THEN UTC_TIMESTAMP() ELSE (F.enddate + INTERVAL :shiftFormEnd DAY ) END AS formEnd,\n" + " _efk_TestForm AS formKey, \n" + " FormID, \n" + " F.Language, \n" + " M.mode,\n" + " M.testkey, \n" + " W.sessionType AS windowSession, \n" + " M.sessionType AS modeSession\n" + "FROM configs.client_testwindow W\n" + "JOIN configs.client_testmode M ON\n" + " M.testid = W.testid AND\n" + " M.clientname = W.clientname AND\n" + " (M.sessionType = -1 OR M.sessionType = 0) \n" + "JOIN configs.client_testformproperties F ON \n" + " M.testkey = F.testkey AND\n" + " F.testid = W.testid AND\n" + " F.clientname = W.clientname AND\n" + " UTC_TIMESTAMP() BETWEEN CASE WHEN F.startDate IS NULL THEN UTC_TIMESTAMP() ELSE (F.startdate + INTERVAL :shiftFormStart DAY) END\n" + " AND CASE WHEN F.enddate IS NULL THEN UTC_TIMESTAMP() ELSE (F.enddate + INTERVAL :shiftFormEnd DAY) END \n" + "WHERE W.clientname = :clientName AND \n" + " W.testid = :assessmentId AND \n" + " (W.sessionType = -1 OR W.sessionType = 0) AND \n" + " UTC_TIMESTAMP() BETWEEN CASE WHEN W.startDate IS NULL THEN UTC_TIMESTAMP() ELSE (W.startDate + INTERVAL :shiftWindowStart DAY) END\n" + " AND CASE WHEN W.endDate IS NULL THEN UTC_TIMESTAMP() ELSE (W.endDate + INTERVAL :shiftWindowEnd DAY ) END \n" + "UNION (\n" + "SELECT\n" + " windowID, \n" + " W.numopps AS windowMax, \n" + " M.maxopps AS modeMax,\n" + " CASE WHEN W.startDate IS NULL THEN UTC_TIMESTAMP() ELSE (W.startDate + INTERVAL :shiftWindowStart DAY) END AS startDate ,\n" + " CASE WHEN W.endDate IS NULL THEN UTC_TIMESTAMP() ELSE (W.endDate + INTERVAL :shiftWindowEnd DAY) END AS endDate ,\n" + " CASE WHEN F.startDate IS NULL THEN UTC_TIMESTAMP() ELSE ( F.startdate + INTERVAL :shiftFormStart DAY) END AS formStart ,\n" + " CASE WHEN F.enddate IS NULL THEN UTC_TIMESTAMP() ELSE (F.enddate + INTERVAL :shiftFormEnd DAY ) END AS formEnd,\n" + " _efk_TestForm AS formKey, \n" + " FormID, \n" + " F.Language, \n" + " M.mode, \n" + " M.testkey AS TestKey, \n" + " W.sessionType , \n" + " M.sessionType\n" + "FROM \n" + " configs.client_segmentproperties S\n" + " JOIN configs.client_testformproperties F ON \n" + " S.clientname = :clientName\n" + " AND S.parentTest = :assessmentId \n" + " AND S.clientname = F.clientname\n" + " AND UTC_TIMESTAMP() BETWEEN \n" + " ( CASE WHEN F.startDate IS NULL THEN UTC_TIMESTAMP() ELSE (F.startdate + INTERVAL :shiftFormStart DAY) END )\n" + " AND ( CASE WHEN F.enddate IS NULL THEN UTC_TIMESTAMP() ELSE (F.enddate + INTERVAL :shiftFormEnd DAY) END )\n" + " AND S.segmentid = F.testid\n" + " JOIN configs.client_testmode M ON\n" + " F.clientname = M.clientname\n" + " AND S.parentTest = M.testID \n" + " AND (M.sessionType = -1 OR M.sessionType = :sessionType) \n" + " AND S.modekey = M.testkey\n" + " JOIN configs.client_testwindow W ON\n" + " M.clientname = W.clientname\n" + " AND W.testID = S.parentTest \n" + " AND (W.sessionType = -1 OR W.sessionType = :sessionType)\n" + " AND UTC_TIMESTAMP() BETWEEN\n" + " ( CASE WHEN W.startDate IS NULL THEN UTC_TIMESTAMP() ELSE (W.startDate + INTERVAL :shiftWindowStart DAY) END )\n" + " AND ( CASE WHEN W.endDate IS NULL THEN UTC_TIMESTAMP() ELSE (W.endDate + INTERVAL :shiftWindowEnd DAY ) END )\n" + ");"; return jdbcTemplate.query(SQL, parameters, (rs, rowNum) -> new AssessmentWindow.Builder().withWindowId(rs.getString("windowId")) .withAssessmentKey(rs.getString("testkey")).withFormKey(rs.getString("formKey")) .withMode(rs.getString("mode")).withWindowMaxAttempts(rs.getInt("windowMax")) .withModeMaxAttempts(rs.getInt("modeMax")) .withStartTime(mapTimestampToJodaInstant(rs, "startDate")) .withEndTime(mapTimestampToJodaInstant(rs, "endDate")).build()); }
From source file:com.blackducksoftware.tools.appedit.naiaudit.dao.jdbc.JdbcVulnNaiAuditDetailsDao.java
/** * Get a map containing all NAI Audit Details for the given application. * * @param applicationId//from www . j a va2s . co m * @return * @throws AppEditException */ @Override public Map<AppCompVulnKey, VulnNaiAuditDetails> getVulnNaiAuditDetailsMap(final String applicationId) { final String SQL = SQL_SELECT_ALL_VULNERABILITIES_FOR_APP; final SqlParameterSource namedParameters = new MapSqlParameterSource("appId", applicationId); logger.debug("Getting vulnNaiAuditDetails for appID " + applicationId + "; SQL: " + SQL); List<VulnNaiAuditDetails> vulnNaiAuditDetailsList = null; try { vulnNaiAuditDetailsList = jdbcTemplate.query(SQL, namedParameters, new VulnNaiAuditDetailsMapper()); } catch (final BadSqlGrammarException e) { final String msg = "Error getting NAI Audit details. Make sure the NAI Audit database tables have been created. Details: " + e.getMessage(); logger.error(msg); throw new IllegalStateException(msg); } logger.debug("Read " + vulnNaiAuditDetailsList.size() + " vulnNaiAuditDetail records."); final Map<AppCompVulnKey, VulnNaiAuditDetails> vulnNaiAuditDetailsMap = new HashMap<>(); for (final VulnNaiAuditDetails vulnNaiAuditDetails : vulnNaiAuditDetailsList) { logger.info("VulnNaiAuditDetails: " + vulnNaiAuditDetails); vulnNaiAuditDetailsMap.put(vulnNaiAuditDetails.getAppCompVulnKey(), vulnNaiAuditDetails); } return vulnNaiAuditDetailsMap; }
From source file:tds.assessment.repositories.impl.AssessmentQueryRepositoryImpl.java
@Override public Optional<Assessment> findAssessmentByKey(final String clientName, final String assessmentKey) { /*/*from w w w . j av a2 s. co m*/ This method fetches the base assessment object 1. itembank.tblsetofadminsubjects - contains the structure of the assessment and segment along with some metadata 2. configs.client_testproperties - contains client specific information for the assessment 3. configs.client_segmentproperties - contains client specific information for segments (if the assessment is segmented) 4. itembank.tblsubject - subject information for the assessment (i.e. MATH, ELA) */ SqlParameterSource parameters = new MapSqlParameterSource("key", assessmentKey).addValue("clientName", clientName); String SQL = ASSESSMENT_SELECT_SQL + "FROM \n" + " itembank.tblsetofadminsubjects A \n" + "JOIN \n" + " configs.client_testproperties CT \n" + " ON CT.testid = A.testid \n " + " OR CT.testid = (\n" + " SELECT parentTsa.testid \n" + " FROM itembank.tblsetofadminsubjects tsa \n" + " JOIN itembank.tblsetofadminsubjects parentTsa ON tsa.virtualtest = parentTsa._key \n" + " WHERE tsa._key = A._key \n" + " ) \n" + "LEFT JOIN \n" + " configs.client_segmentproperties SP \n" + " ON SP.segmentid = A.testid \n" + " AND SP.clientName = :clientName \n" + "JOIN \n" + " itembank.tblclient CL \n" + " ON (CL.name = SP.clientname OR CL.name = CT.clientname) \n" + "LEFT JOIN \n" + " itembank.tbltestadmin TA \n" + " ON TA._fk_client = CL._key \n" + "LEFT JOIN \n" + " itembank.tblsubject S \n" + " ON S._key = A._fk_Subject \n" + "WHERE \n" + " (A.virtualtest = :key OR A._key = :key) \n" + " AND (CT.clientname = :clientName OR SP.clientname = :clientName) \n" + "ORDER BY \n" + " assessmentKey DESC, \n" + " A.testPosition"; List<Map<String, Object>> rows = jdbcTemplate.queryForList(SQL, parameters); Optional<Assessment> maybeAssessment = Optional.empty(); if (rows.isEmpty()) { logger.debug("Could not find an Assessment in tblsetofadminsubjects using key = '%s'", assessmentKey); } else { maybeAssessment = assessmentMapper.mapResults(rows); } return maybeAssessment; }
From source file:com.daugherty.e2c.persistence.data.jdbc.JdbcSupplierDao.java
@Override public String loadSupplierIdMatchingLegacyId(Long legacyId) { LOGGER.debug("Looking up product ID matching legacy id " + legacyId); String sql = getSql("supplier/load-id-matching-legacy-id.sql"); SqlParameterSource parameterSource = new MapSqlParameterSource("legacyId", legacyId); return jdbcTemplate.queryForObject(sql, parameterSource, String.class); }
From source file:org.mulima.internal.freedb.FreeDbJdbcDaoImpl.java
/** * Gets the tracks for the disc id.//from w ww.j ava2s .co m * @param id the id of the disc * @return the list of tracks */ private List<Track> getTracksForDisc(int id) { final String sql = "SELECT * FROM `tracks` WHERE `disc_id`=:id"; SqlParameterSource parms = new MapSqlParameterSource("id", id); return this.getNamedParameterJdbcTemplate().query(sql, parms, new TrackRowMapper()); }
From source file:tds.assessment.repositories.impl.AssessmentQueryRepositoryImplIntegrationTests.java
@Before public void setUp() { String tblClientInsertSQL = "INSERT INTO tblclient VALUES (1,'SBAC_PT',NULL,'/usr/local/tomcat/resources/tds/');"; String tblSubjectInsertSQL = "INSERT INTO tblsubject VALUES ('ELA','','SBAC_PT-ELA',1,8185,NULL);"; // Non-segmented, test String tblSetOfAdminSubjectsInsertSQL1 = "INSERT INTO itembank.tblsetofadminsubjects VALUES ('(SBAC_PT)IRP-Perf-ELA-11-Summer-2015-2016','SBAC_PT', 'SBAC_PT-ELA','IRP-Perf-ELA-11'," + "0,1,4,4,1,1,3,7,1,4,NULL,'virtual',NULL,5,1,20,1,5,NULL,NULL,1,1,2112,1184,5,0,'Oregon',NULL,'ABILITY',NULL,1,NULL,1,1,NULL,NULL,0,0,0,0," + "0,'bp1',NULL,NULL,'summative');"; // Segmented test assessment String tblSetOfAdminSubjectsInsertSQL2 = "INSERT INTO itembank.tblsetofadminsubjects VALUES ('(SBAC_PT)SBAC-Mathematics-8-Spring-2013-2015','SBAC_PT', 'SBAC_PT-ELA','SBAC-Mathematics-8'," + "0,1,4,4,1,1,NULL,NULL,0,0,NULL,'virtual',NULL,5,1,20,1,5,NULL,NULL,1,1,8185,8185,5,0,'SBAC_PT',NULL,'ABILITY',NULL,1,NULL,1,1,NULL,NULL,0,0,0,0," + "0,'bp1',NULL,NULL,'summative');"; // Segment 1/*from w w w . j av a2 s. co m*/ String tblSetOfAdminSubjectsInsertSQL2a = "INSERT INTO itembank.tblsetofadminsubjects VALUES ('(SBAC_PT)SBAC-SEG1-MATH-8-Spring-2013-2015','SBAC_PT', 'SBAC_PT-ELA','SBAC-SEG1-MATH-8'," + "0,1,4,4,1,1,3,6,2,3,NULL,'fixedform',NULL,5,1,20,1,5,'(SBAC_PT)SBAC-Mathematics-8-Spring-2013-2015',1,0,1,8185,8185,5,0,'SBAC_PT',NULL,'ABILITY',NULL,1,NULL,1,1,NULL,NULL,0,0,0,0," + "0,'bp1',NULL,NULL,'summative');"; // Segment2 String tblSetOfAdminSubjectsInsertSQL2b = "INSERT INTO itembank.tblsetofadminsubjects VALUES ('(SBAC_PT)SBAC-SEG2-MATH-8-Spring-2013-2015','SBAC_PT', 'SBAC_PT-ELA','SBAC-SEG2-MATH-8'," + "0,1,4,4,1,1,7,11,1,4,NULL,'fixedform',NULL,5,1,20,1,5,'(SBAC_PT)SBAC-Mathematics-8-Spring-2013-2015',2,0,1,8185,8185,5,0,'SBAC_PT',NULL,'ABILITY',NULL,1,NULL,1,1,NULL,NULL,0,0,0,0," + "0,'bp1',NULL,NULL,'summative');"; // Segment2 - SBAC client String tblSetOfAdminSubjectsSBACInsertSQL = "INSERT INTO itembank.tblsetofadminsubjects VALUES ('(SBAC)SBAC-SEG2-MATH-8-Spring-2013-2015','SBAC', 'SBAC-ELA','SBAC-SEG2-MATH-8'," + "0,1,4,4,1,1,NULL,NULL,1,4,NULL,'fixedform',NULL,5,1,20,1,5,'(SBAC)SBAC-Mathematics-8-Spring-2013-2015',2,0,1,8185,8185,5,0,'SBAC_PT',NULL,'ABILITY',NULL,1,NULL,1,1,NULL,NULL,0,0,0,0," + "0,'bp1',NULL,NULL,'summative');"; final String itemConstraintsInsertSql = "INSERT INTO \n" + " configs.client_test_itemconstraint(clientname, testid, propname, propvalue, tooltype, toolvalue, item_in) \n" + "VALUES \n" + " ('SBAC_PT', 'IRP-Perf-ELA-11', '--ITEMTYPE--', 'ER', 'Item Types Exclusion', 'TDS_ItemTypeExcl_ER', 0), \n" + " ('SBAC_PT', 'IRP-Perf-ELA-11', '--ITEMTYPE--', 'MI', 'Item Types Exclusion', 'TDS_ItemTypeExcl_MI', 0), \n" + " ('SBAC_PT', 'IRP-Perf-ELA-11', '--ITEMTYPE--', 'WER', 'Item Types Exclusion', 'TDS_ItemTypeExcl_WER', 0), \n" + " ('SBAC_PT', 'IRP-Perf-ELA-11', 'Language', 'ENU', 'Language', 'ENU', 1), \n" + " ('SBAC_PT', 'IRP-Perf-ELA-3', '--ITEMTYPE--', 'ER', 'Item Types Exclusion', 'TDS_ItemTypeExcl_ER', 0), \n" + " ('SBAC_PT', 'IRP-Perf-ELA-3', '--ITEMTYPE--', 'MI', 'Item Types Exclusion', 'TDS_ItemTypeExcl_MI', 0), \n" + " ('SBAC_PT', 'IRP-Perf-ELA-3', '--ITEMTYPE--', 'WER', 'Item Types Exclusion', 'TDS_ItemTypeExcl_WER', 0), \n" + " ('SBAC_PT', 'IRP-Perf-ELA-3', 'Language', 'ENU', 'Language', 'ENU', 1)"; SqlParameterSource parameters = new MapSqlParameterSource("ftstartDate", ResultSetMapperUtility.mapJodaInstantToTimestamp(Instant.now())); final String clientTestPropertiesInsertSQL = "INSERT INTO configs.client_testproperties (clientname, testid, ftstartdate, accommodationfamily, maxopportunities, abilityslope, abilityintercept, initialabilitybysubject, prefetch, validatecompleteness, deleteUnansweredItems, label, msb, handscoreproject, subjectname) VALUES " + "('SBAC_PT', 'IRP-Perf-ELA-11', :ftstartDate, 'family', 99, 1.5, 2.3, 1, 2, 1, 0, 'Grade 11 ELA Perf', 1, 1234, 'ELA'), \n" + "('SBAC_PT', 'SBAC-Mathematics-8', :ftstartDate, 'otherFamily', 95, 5.5, 6.3, 0, 2, 1, 0, 'Grade 8 Math', 0, 4321, 'MATH');\n"; SqlParameterSource segPropsParams = new MapSqlParameterSource("ftstartdate", ResultSetMapperUtility.mapJodaInstantToTimestamp(segFtStartDate)).addValue("ftenddate", ResultSetMapperUtility.mapJodaInstantToTimestamp(segFtEndDate)); final String clientSegmentPropertiesInsertSQL = "INSERT INTO configs.client_segmentproperties (ispermeable, clientname, entryapproval, exitapproval, itemreview, segmentid, segmentposition, parenttest, ftstartdate, ftenddate, label, modekey) VALUES " + "(1, 'SBAC_PT', 0, 0, 0, 'SBAC-SEG1-MATH-8', 1, 'SBAC-Mathematics-8', :ftstartdate, :ftenddate, 'Grade 8 MATH segment', '(SBAC_PT)SBAC-Mathematics-8-Spring-2013-2015'), \n" + "(1, 'SBAC_PT', 0, 0, 0, 'SBAC-SEG2-MATH-8', 2, 'SBAC-Mathematics-8', :ftstartdate, :ftenddate, 'Grade 8 MATH segment', '(SBAC_PT)SBAC-Mathematics-8-Spring-2013-2015')"; final String tblTestAdminInsertSQL = "INSERT INTO itembank.tbltestadmin (schoolyear, season, _key, _fk_client) " + "VALUES ('2112-2113', 'winter', 'SBAC_PT', 1)"; final String testToolTypeInsertSQL = "INSERT INTO configs.client_testtooltype (clientname, context, contexttype, toolname, allowchange, rtsfieldname, isrequired, isselectable, dateentered, testmode) " + "VALUES ('SBAC_PT', 'IRP-Perf-ELA-11', 'TEST', 'Language', 0, 'rts', 1, 0, now(), 'ALL'), " + "('SBAC_PT', 'SBAC-Mathematics-8', 'TEST', 'Language', 0, 'rts', 1, 0, now(), 'ALL');"; final String testToolInsertSQL = "INSERT INTO configs.client_testtool (clientname, context, contexttype, type, code, value, isdefault, allowcombine, testmode) " + "VALUES ('SBAC_PT', 'IRP-Perf-ELA-11', 'TEST', 'Language', 'ENU', 'ENU', 1, 0, 'ALL'), " + "('SBAC_PT', 'IRP-Perf-ELA-11', 'TEST', 'Language', 'FRN', 'FRN', 1, 0, 'ALL'), " + "('SBAC_PT', 'SBAC-Mathematics-8', 'TEST', 'Language', 'ENU', 'ENU', 1, 0, 'ALL');"; final String setOfTestGradesInsertSql = "INSERT INTO itembank.setoftestgrades (testid, grade, _fk_adminsubject, _key) " + "VALUES ('IRP-Perf-ELA-11', '3', '(SBAC_PT)IRP-Perf-ELA-11-Summer-2015-2016', 0x8ebc29966a52401b952e45b1a2d08e3f), " + "('IRP-Perf-ELA-11', '11', '(SBAC_PT)IRP-Perf-ELA-11-Summer-2015-2016', 0x8ebc29966a52401b952e45b1a2d08e3e)," + "('SBAC-Mathematics-8', 'Kindergarden', '(SBAC_PT)SBAC-Mathematics-8-Spring-2013-2015', 0x8ebc29966a52401b952e45b1a2d08e3c)"; jdbcTemplate.update(itemConstraintsInsertSql, new MapSqlParameterSource()); jdbcTemplate.update(tblClientInsertSQL, new MapSqlParameterSource()); jdbcTemplate.update(tblSubjectInsertSQL, new MapSqlParameterSource()); jdbcTemplate.update(tblSetOfAdminSubjectsInsertSQL1, new MapSqlParameterSource()); jdbcTemplate.update(tblSetOfAdminSubjectsInsertSQL2, new MapSqlParameterSource()); jdbcTemplate.update(tblSetOfAdminSubjectsInsertSQL2a, new MapSqlParameterSource()); jdbcTemplate.update(tblSetOfAdminSubjectsInsertSQL2b, new MapSqlParameterSource()); jdbcTemplate.update(tblSetOfAdminSubjectsSBACInsertSQL, new MapSqlParameterSource()); jdbcTemplate.update(clientTestPropertiesInsertSQL, parameters); jdbcTemplate.update(clientSegmentPropertiesInsertSQL, segPropsParams); jdbcTemplate.update(tblTestAdminInsertSQL, new MapSqlParameterSource()); jdbcTemplate.update(testToolTypeInsertSQL, new MapSqlParameterSource()); jdbcTemplate.update(testToolInsertSQL, new MapSqlParameterSource()); jdbcTemplate.update(setOfTestGradesInsertSql, new MapSqlParameterSource()); }
From source file:io.lavagna.service.CardRepository.java
@Transactional(readOnly = false) private void moveLastCardAtTop(int lastCardId, int columnId) { queries.incrementCardsOrder(columnId); SqlParameterSource updateParam = new MapSqlParameterSource("columnId", columnId) .addValue("cardId", lastCardId).addValue("cardOrder", 0); jdbc.update(queries.updateCardOrder(), updateParam); }
From source file:com.eu.evaluation.server.service.impl.eva.UpAndDownEvaluate.java
/** * ??/*from w ww. j a v a 2 s . c o m*/ * * @param ev * @param instanceID ??ID * @return */ private Long countUp(UpAndDownEvlauateItemHistory ev, AccessSystem accessSystem, String instanceID) { //??or.self = ?or.parent = ObjectRelation or = objectRelationDAO.findByParent(ev.getObjectDictionary().getInstanceClass(), ev.getUpEntity().getInstanceClass()); if (or == null) { throw new RuntimeException( "?? = " + ev.getObjectDictionary().getDisplayname() + " ; = " + ev.getUpEntity().getDisplayname() + "?"); } //sql? String jpql = "select count(*) from {0} t where t.id = :id and t.evaluateVersion.id = :evid and t.position = :position and exists (select 1 from {1} p where p.evaluateVersion.id = t.evaluateVersion.id and p.position = t.position and p.id = t.{2}"; if (or.isSimpleProperty()) {//??p.id = t.field? jpql += ")"; } else {//???p.id = t.field.id? jpql += ".id)"; } jpql = MessageFormat.format(jpql, new Object[] { or.getSelfClass(), or.getRelationClass(), or.getPropertyName() }); MapSqlParameterSource params = new MapSqlParameterSource("id", instanceID); params.addValue("evid", ev.getEvaluateVersion().getId()); params.addValue("position", accessSystem.getCode()); logger.debug("sql" + jpql + "\n; ? = " + instanceID); return defaultDAO.executeCount(jpql, params); }