/** * Retrieves the primary key from acl_sid, creating a new row if needed and the * allowCreate property is true. * @param sidName name of Sid to find or to create * @param sidIsPrincipal whether it's a user or granted authority like role * @param allowCreate true if creation is permitted if not found * @return the primary key or null if not found */ protected Long createOrRetrieveSidPrimaryKey(String sidName, boolean sidIsPrincipal, boolean allowCreate) { List<Long> sidIds = jdbcOperations.queryForList(selectSidPrimaryKey, new Object[] { Boolean.valueOf(sidIsPrincipal), sidName }, Long.class); if (!sidIds.isEmpty()) { return sidIds.get(0); } if (allowCreate) { jdbcOperations.update(insertSid, Boolean.valueOf(sidIsPrincipal), sidName); Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running"); return jdbcOperations.queryForObject(sidIdentityQuery, Long.class); } return null; }
/** * Retrieves the primary key from {@code acl_class}, creating a new row if needed and * the {@code allowCreate} property is {@code true}. * * @param type to find or create an entry for (often the fully-qualified class name) * @param allowCreate true if creation is permitted if not found * * @return the primary key or null if not found */ protected Long createOrRetrieveClassPrimaryKey(String type, boolean allowCreate, Class idType) { List<Long> classIds = jdbcOperations.queryForList(selectClassPrimaryKey, new Object[] { type }, Long.class); if (!classIds.isEmpty()) { return classIds.get(0); } if (allowCreate) { if (!isAclClassIdSupported()) { jdbcOperations.update(insertClass, type); } else { jdbcOperations.update(insertClass, type, idType.getCanonicalName()); } Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running"); return jdbcOperations.queryForObject(classIdentityQuery, Long.class); } return null; }
@Before public void onSetUp() throws Exception { jdbcTemplate.update("delete from TRADE"); List<Map<String, Object>> list = jdbcTemplate.queryForList("select NAME, CREDIT from CUSTOMER"); for (Map<String, Object> map : list) { credits.put((String) map.get("NAME"), ((Number) map.get("CREDIT")).doubleValue()); } }
@Before public void onSetUp() throws Exception { jdbcTemplate.update("delete from TRADE"); jdbcTemplate.update("delete from CUSTOMER where ID > 4"); jdbcTemplate.update("update CUSTOMER set credit=100000"); List<Map<String, Object>> list = jdbcTemplate.queryForList("select name, CREDIT from CUSTOMER"); for (Map<String, Object> map : list) { credits.put((String) map.get("NAME"), ((Number) map.get("CREDIT")).doubleValue()); } }
@Override protected <T> List<T> doQueryForList(final String sql, final SqlSingleValueRowMapper rowMapper, final Class<T> type, Object[] objects) { List<T> list = jdbcTemplate.queryForList(sql, objects, type); return Lists.transform(list, new Function<T, T>() { int i = 0; public T apply(T input) { return rowMapper.mapRow(type, input, i++); }; }); }
@Override public Integer getPortalUserId(String userName) { final List<Integer> results = this.jdbcOperations.queryForList( "SELECT USER_ID FROM UP_USER WHERE USER_NAME=?", Integer.class, userName); return DataAccessUtils.singleResult(results); }
@Override public Integer getPortalUserId(String userName) { final List<Integer> results = this.jdbcOperations.queryForList( "SELECT USER_ID FROM UP_USER WHERE USER_NAME=?", Integer.class, userName); return DataAccessUtils.singleResult(results); }
@Override public String getPortalUserName(final int uPortalUID) { final List<String> results = this.jdbcOperations.queryForList( "SELECT USER_NAME FROM UP_USER WHERE USER_ID=?", String.class, uPortalUID); return DataAccessUtils.singleResult(results); }
@Override public String getPortalUserName(final int uPortalUID) { final List<String> results = this.jdbcOperations.queryForList( "SELECT USER_NAME FROM UP_USER WHERE USER_ID=?", String.class, uPortalUID); return DataAccessUtils.singleResult(results); }
@Override public Iterable<? extends IPortalData> getPortalData() { final List<String> userList = this.jdbcOperations.queryForList("SELECT USER_NAME FROM UP_USER", String.class); return Lists.transform( userList, (Function<String, IPortalData>) userName -> new SimpleStringPortalData(userName, null, null)); }
public List<Map<String, Object>> queryForList(String sql, Object... args) throws DataAccessException { return (ObjectUtils.isEmpty(args) ? getJdbcOperations().queryForList(sql) : getJdbcOperations().queryForList(sql, getArguments(args))); }
@Cacheable( cacheName = "org.apereo.portal.EntityTypes.ID_BY_CLASS", keyGeneratorName = ListCacheKeyGenerator.DEFAULT_BEAN_NAME) public Integer getEntityIDFromType(Class<? extends IBasicEntity> type) { return DataAccessUtils.singleResult( this.jdbcOperations.queryForList( "SELECT ENTITY_TYPE_ID FROM UP_ENTITY_TYPE WHERE ENTITY_TYPE_NAME = ?", Integer.class, type.getName())); }
@Cacheable( cacheName = "org.apereo.portal.EntityTypes.ID_BY_CLASS", keyGeneratorName = ListCacheKeyGenerator.DEFAULT_BEAN_NAME) public Integer getEntityIDFromType(Class<? extends IBasicEntity> type) { return DataAccessUtils.singleResult( this.jdbcOperations.queryForList( "SELECT ENTITY_TYPE_ID FROM UP_ENTITY_TYPE WHERE ENTITY_TYPE_NAME = ?", Integer.class, type.getName())); }
public Map<String, Object> queryRowMap(Criteria criteria) { BoundSql boundSql = criteria.build(true, getMappingHandler()); List<Map<String, Object>> mapList = jdbcTemplate.queryForList(boundSql.getSql(), boundSql.getParameters() .toArray()); return mapList == null || mapList.isEmpty() ? null : mapList.iterator().next(); }
/** * 查询多行结果封装为Map列表 * * @return Map数组 */ public List<Map<String, Object>> queryMapList() { checkNull(); if (this.useClassicJdbcTemplate) { return this.namedParameterJdbcTemplate.getJdbcOperations().queryForList(strBuilder.toString(), varParams); } return this.namedParameterJdbcTemplate.queryForList(strBuilder.toString(), this.sqlParameterSource); }
public Map<String, Object> queryRowMap(Criteria criteria) { BoundSql boundSql = criteria.mappingHandler(getMappingHandler()).build(true); List<Map<String, Object>> mapList = jdbcTemplate.queryForList(boundSql.getSql(), boundSql.getParameters() .toArray()); return mapList == null || mapList.isEmpty() ? null : mapList.iterator().next(); }
public List<Map<String, Object>> queryListForSql(String refSql, String expectParamKey, Object[] params) { BoundSql boundSql = this.sqlFactory.getBoundSql(refSql, expectParamKey, params); List<Map<String, Object>> mapList = jdbcTemplate.queryForList(boundSql.getSql(), boundSql.getParameters() .toArray()); return mapList; }
public List<Map<String, Object>> queryListForSql(String refSql, String expectParamKey, Object[] params) { BoundSql boundSql = this.sqlFactory.getBoundSql(refSql, expectParamKey, params); List<Map<String, Object>> mapList = jdbcTemplate.queryForList(boundSql.getSql(), boundSql.getParameters() .toArray()); return mapList; }
public List<Map<String, Object>> queryRowMapList(Criteria criteria) { BoundSql boundSql = criteria.build(true, getMappingHandler()); List<Map<String, Object>> mapList = jdbcTemplate.queryForList(boundSql.getSql(), boundSql.getParameters() .toArray()); return mapList; }
public List<Map<String, Object>> queryRowMapList(Criteria criteria) { BoundSql boundSql = criteria.mappingHandler(getMappingHandler()).build(true); List<Map<String, Object>> mapList = jdbcTemplate.queryForList(boundSql.getSql(), boundSql.getParameters() .toArray()); return mapList; }