当前位置: 首页>>代码示例>>Java>>正文


Java DataRetrievalFailureException类代码示例

本文整理汇总了Java中org.springframework.dao.DataRetrievalFailureException的典型用法代码示例。如果您正苦于以下问题:Java DataRetrievalFailureException类的具体用法?Java DataRetrievalFailureException怎么用?Java DataRetrievalFailureException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataRetrievalFailureException类属于org.springframework.dao包,在下文中一共展示了DataRetrievalFailureException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKey

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
@Override
public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException {
	if (this.keyList.size() == 0) {
		return null;
	}
	if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) {
		throw new InvalidDataAccessApiUsageException(
				"The getKey method should only be used when a single key is returned.  " +
				"The current key entry contains multiple keys: " + this.keyList);
	}
	Iterator<Object> keyIter = this.keyList.get(0).values().iterator();
	if (keyIter.hasNext()) {
		Object key = keyIter.next();
		if (!(key instanceof Number)) {
			throw new DataRetrievalFailureException(
					"The generated key is not of a supported numeric type. " +
					"Unable to cast [" + (key != null ? key.getClass().getName() : null) +
					"] to [" + Number.class.getName() + "]");
		}
		return (Number) key;
	}
	else {
		throw new DataRetrievalFailureException("Unable to retrieve the generated key. " +
				"Check that the table has an identity column enabled.");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:GeneratedKeyHolder.java

示例2: executeSubQuery

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
private String executeSubQuery(Junction junction, List<Criterion> criteria) {
        List<String> indices = getIndexNames(junction, entityPersister);

        if (indices.isEmpty()) {
            throw new DataRetrievalFailureException("Unsupported Redis query");
        }
        if (indices.size() == 1) {
            return indices.get(0);
        }
        final String[] keyArray = indices.toArray(new String[indices.size()]);
        String finalKey;
        if (junction instanceof Conjunction) {
            finalKey = formulateConjunctionKey(indices);
            template.sinterstore(finalKey, keyArray);
        }
        else {
            finalKey = formulateDisjunctionKey(indices);
            template.sunionstore(finalKey, keyArray);
        }

        //  since the keys used for queries are temporary we set Redis to kill them after a while
//        template.expire(finalKey, 1000);
        return finalKey;
    }
 
开发者ID:grails,项目名称:gorm-redis,代码行数:25,代码来源:RedisQuery.java

示例3: singleKeyNonNumeric

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
@Test
public void singleKeyNonNumeric() {
	kh.getKeyList().addAll(singletonList(singletonMap("key", "1")));

	exception.expect(DataRetrievalFailureException.class);
	exception.expectMessage(startsWith("The generated key is not of a supported numeric type."));
	kh.getKey().intValue();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:KeyHolderTests.java

示例4: fetchPatientDemographics

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
private VistaDataChunk fetchPatientDemographics(String vistaId, String pid, boolean isIcn) {
    Timer.Context timer = metricRegistry.timer(MetricRegistry.name("vpr.fetch.patient")).time();
    try {
        Map rpcArg = new HashMap();
        rpcArg.put("patientId", (isIcn ? ";" + pid : pid));
        rpcArg.put("domain", "patient");
        rpcArg.put("extractSchema",EXTRACT_SCHEMA);
        RpcResponse response = synchronizationRpcTemplate.execute(VISTA_RPC_BROKER_SCHEME + "://" + vistaId + VPR_GET_VISTA_DATA_JSON_RPC_URI, rpcArg);
        JsonNode json = jsonExtractor.extractData(response);
        JsonNode patientJsonNode = json.path("data").path("items").path(0);
        if (patientJsonNode.isNull())
            throw new DataRetrievalFailureException("missing 'data.items[0]' node in JSON RPC response");
        VistaDataChunk patientChunk = VistaDataChunk.createVistaDataChunk(vistaId, response.getRequestUri(), patientJsonNode, "patient", 0, 1, null, VistaDataChunk.getProcessorParams(vistaId, pid, isIcn));
        patientChunk.getParams().put(SyncMessageConstants.DIVISION, response.getDivision());
        patientChunk.getParams().put(SyncMessageConstants.DIVISION_NAME, response.getDivisionName());

        if (!isIcn)
            patientChunk.setLocalPatientId(pid);

        return patientChunk;
    } catch (RuntimeException e) {
        throw e;
    } finally {
        timer.stop();
    }
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:27,代码来源:VistaVprDataExtractEventStreamDAO.java

示例5: fetchOneByUid

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
public VistaDataChunk fetchOneByUid(String vistaId, String pid, String uid) {
    Timer.Context timer = metricRegistry.timer(MetricRegistry.name("vpr.fetch.patient")).time();
    String domain = UidUtils.getCollectionNameFromUid(uid);
    PatientDemographics pt = patientDao.findByPid(pid);
    try {
        Map rpcArg = new HashMap();
        rpcArg.put("uid", uid);
        RpcResponse response = synchronizationRpcTemplate.execute(VISTA_RPC_BROKER_SCHEME + "://" + vistaId + VPR_GET_VISTA_DATA_JSON_RPC_URI, rpcArg);
        JsonNode json = jsonExtractor.extractData(response);
        JsonNode jsonNode = json.path("data").path("items").path(0);
        if (jsonNode.isNull())
            throw new DataRetrievalFailureException("missing 'data.items[0]' node in JSON RPC response");
        VistaDataChunk chunk = VistaDataChunk.createVistaDataChunk(vistaId, response.getRequestUri(), jsonNode, domain, 0, 1, pt);

        return chunk;
    } catch (RuntimeException e) {
        throw e;
    } finally {
        timer.stop();
    }
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:22,代码来源:VistaVprDataExtractEventStreamDAO.java

示例6: createVistaDataChunks

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
public static List<VistaDataChunk> createVistaDataChunks(String vistaId, String rpcUri, JsonNode jsonResponse, String domain, PatientDemographics pt, Map processorParams) {
    JsonNode itemsNode = jsonResponse.path("data").path("items");
    if (itemsNode.isNull())
        throw new DataRetrievalFailureException("missing 'data.items' node in JSON RPC response");
    List<VistaDataChunk> chunks = new ArrayList<VistaDataChunk>(itemsNode.size());
    for (int i = 0; i < itemsNode.size(); i++) {
        JsonNode item = itemsNode.get(i);
        if (vistaId == null) {
            vistaId = UidUtils.getSystemIdFromPatientUid(item.path("uid").asText());
        }
        if (processorParams == null) {
            processorParams = getProcessorParams(vistaId, pt.getPid(), pt.getIcn() != null);
        }
        chunks.add(createVistaDataChunk(vistaId, rpcUri, item, domain, i, itemsNode.size(), pt, processorParams));
    }
    return chunks;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:18,代码来源:VistaDataChunk.java

示例7: createListFromJsonCResponse

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
private <T> List<T> createListFromJsonCResponse(Class<T> type, JsonNode jsonc) {
    if (!Map.class.isAssignableFrom(type) && !IPOMObject.class.isAssignableFrom(type))
        throw new IllegalArgumentException("[Assertion failed] - type must be of type " + Map.class + " or of type " + IPOMObject.class);
    if (jsonc == null) {
        throw new DataRetrievalFailureException("Unable to fetch all " + type.getName() + "s from " + VPR_GET_OPERATIONAL_DATA_RPC + " because response JSON was null");
    }

    JsonNode dataNode = jsonc.path("data");
    if (dataNode.isNull()) {
        String message = jsonc.path("error").path("message").textValue();
        throw new DataRetrievalFailureException("Unable to fetch all " + type.getName() + "s from " + VPR_GET_OPERATIONAL_DATA_RPC + ": " + message);
    }

    JsonNode itemsNode = jsonc.path("data").path("items");
    List<T> ret = (List<T>) (Map.class.isAssignableFrom(type) ? createListOfMaps(type.asSubclass(Map.class), itemsNode) : createList(type.asSubclass(IPOMObject.class), itemsNode));
    return ret;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:18,代码来源:VistaOperationalDataDAO.java

示例8: testCountUnknownCollection

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
@Test
public void testCountUnknownCollection() throws Exception {
    Map<String, Object> mockFooCount = new HashMap<String, Object>();
    mockFooCount.put("topic", "bar");
    mockFooCount.put("count", 23);

    when(mockJdsTemplate.getForJsonC("/data/all/count/collection")).thenReturn(JsonCCollection.create(singletonList(mockFooCount)));

    try {
        dao.count(Foo.class);
        fail("expected " + DataRetrievalFailureException.class);
    } catch (DataRetrievalFailureException e) {
        // NOOP
    }

    verify(mockJdsTemplate).getForJsonC("/data/all/count/collection");
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:18,代码来源:JdsGenericPOMObjectDAOTests.java

示例9: getCache

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
public Object getCache(final Cache cache, final String cahceName) {
	Element element = null;
	try {
		element = cache.get(cahceName);
	} catch (CacheException cacheException) {
		throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage());
	}

	if (logger.isTraceEnabled()) {
		logger.trace("Cache hit: " + (element != null) + "; Cache name: " + cahceName + " Name: " + cache.getName()
				+ " ,size: " + cache.getSize());
	}

	if (element == null) {
		return null;
	} else {
		return element.getValue();
	}
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:20,代码来源:CacheObjectImpl.java

示例10: getKey

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException {
	if (this.keyList.size() == 0) {
		return null;
	}
	if (this.keyList.size() > 1 || this.keyList.get(0).size() > 1) {
		throw new InvalidDataAccessApiUsageException(
				"The getKey method should only be used when a single key is returned.  " +
				"The current key entry contains multiple keys: " + this.keyList);
	}
	Iterator<Object> keyIter = this.keyList.get(0).values().iterator();
	if (keyIter.hasNext()) {
		Object key = keyIter.next();
		if (!(key instanceof Number)) {
			throw new DataRetrievalFailureException(
					"The generated key is not of a supported numeric type. " +
					"Unable to cast [" + (key != null ? key.getClass().getName() : null) +
					"] to [" + Number.class.getName() + "]");
		}
		return (Number) key;
	}
	else {
		throw new DataRetrievalFailureException("Unable to retrieve the generated key. " +
				"Check that the table has an identity column enabled.");
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:GeneratedKeyHolder.java

示例11: findLocations

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<LocationUpdate> findLocations(String deviceId, Date startDate, Date endDate) {
    logger.info("findLocations:" + deviceId + "," + startDate + "," + endDate);
    DeviceInfo device = deviceInfoRepository.findByDeviceId(deviceId);
    if (device == null) {
        throw new DataRetrievalFailureException("DeviceInfo:" + deviceId);
    }
    List<LocationUpdate> result = new ArrayList<LocationUpdate>();
    Iterable<LocationUpdate> resultSet = locationUpdateRepository
            .findAll(locationUpdate.device.eq(device).and(locationUpdate.locTime.between(startDate, endDate)));
    for (LocationUpdate loc : resultSet) {
        result.add(loc);
    }
    return result;
}
 
开发者ID:corneil,项目名称:spring-data-demo,代码行数:17,代码来源:LocationAndDeviceServiceImpl.java

示例12: parseUsers

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
/**
 * Convenience method for parsing the users.xml file.
 * <p/>
 * <p>This method is synchronized so only one thread at a time
 * can parse the users.xml file and create the <code>principal</code>
 * instance variable.</p>
 */
private void parseUsers() throws DataRetrievalFailureException {
    final HashMap<String, OnmsUser> users = new HashMap<String, OnmsUser>();

    try {
        for (final OnmsUser user : m_userManager.getOnmsUserList()) {
            users.put(user.getUsername(), user);
        }
    } catch (final Throwable t) {
        throw new DataRetrievalFailureException("Unable to get user list.", t);
    }

    log().debug("Loaded the users.xml file with " + users.size() + " users");

    m_usersLastModified = m_userManager.getLastModified();
    m_userFileSize = m_userManager.getFileSize();
    m_users = users;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:SpringSecurityUserDaoImpl.java

示例13: get

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
public Ticket get(String ticketId) {
    try {
        Properties props = getProperties();
        MyQuickBaseClient qdb = createClient(getUserName(props), getPassword(props), getUrl(props));
    
        String dbId = qdb.findDbByName(getApplicationName(props));
        
        HashMap<String, String> record = qdb.getRecordInfo(dbId, ticketId);
        
        Ticket ticket = new Ticket();
        ticket.setId(ticketId);
        ticket.setModificationTimestamp(record.get(getModificationTimeStampFile(props)));
        ticket.setSummary(record.get(getSummaryField(props)));
        ticket.setDetails(record.get(getDetailsField(props)));
        ticket.setState(getTicketStateValue(record.get(getStateField(props)), props));
        
        return ticket;
       
    } catch (Throwable e) {
        throw new DataRetrievalFailureException("Failed to commit QuickBase transaction: "+e.getMessage(), e);
    }
   
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:QuickBaseTicketerPlugin.java

示例14: scheduleBackgroundInitTask

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
private void scheduleBackgroundInitTask() {
    ReadyRunnable interfaceScheduler = new ReadyRunnable() {

        public boolean isReady() {
            return true;
        }

        public void run() {
            //
            try {
                scheduleExistingInterfaces();
            } catch (DataRetrievalFailureException sqlE) {
                log().error("start: Failed to schedule existing interfaces", sqlE);
            } finally {
                setSchedulingCompleted(true);
            }

        }
    };

    m_scheduler.schedule(interfaceScheduler, 0);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:23,代码来源:Threshd.java

示例15: translateExceptionIfPossible

import org.springframework.dao.DataRetrievalFailureException; //导入依赖的package包/类
@Nullable
@Override
public DataAccessException translateExceptionIfPossible(RuntimeException exception) {

	Assert.notNull(exception, "Exception must not be null!");

	if (exception instanceof DataAccessException) {
		return (DataAccessException) exception;
	}

	if (exception instanceof NoSuchElementException || exception instanceof IndexOutOfBoundsException
			|| exception instanceof IllegalStateException) {
		return new DataRetrievalFailureException(exception.getMessage(), exception);
	}

	if (exception.getClass().getName().startsWith("java")) {
		return new UncategorizedKeyValueException(exception.getMessage(), exception);
	}

	return null;
}
 
开发者ID:spring-projects,项目名称:spring-data-keyvalue,代码行数:22,代码来源:KeyValuePersistenceExceptionTranslator.java


注:本文中的org.springframework.dao.DataRetrievalFailureException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。