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


Java ObjectRetrievalFailureException类代码示例

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


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

示例1: findById

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits}
 * for the corresponding owner, if not already loaded.
 */
@Override
public Owner findById(int id) throws DataAccessException {
    Owner owner;
    try {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        owner = this.namedParameterJdbcTemplate.queryForObject(
            "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
            params,
            BeanPropertyRowMapper.newInstance(Owner.class)
        );
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Owner.class, id);
    }
    loadPetsAndVisits(owner);
    return owner;
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:22,代码来源:JdbcOwnerRepositoryImpl.java

示例2: findById

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
@Override
public Pet findById(int id) throws DataAccessException {
    JdbcPet pet;
    try {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        pet = this.namedParameterJdbcTemplate.queryForObject(
            "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
            params,
            new JdbcPetRowMapper());
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Pet.class, id);
    }
    Owner owner = this.ownerRepository.findById(pet.getOwnerId());
    owner.addPet(pet);
    pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId()));

    List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
    for (Visit visit : visits) {
        pet.addVisit(visit);
    }
    return pet;
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:24,代码来源:JdbcPetRepositoryImpl.java

示例3: loadOwner

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads
 * the {@link Pet Pets} and {@link Visit Visits} for the corresponding
 * owner, if not already loaded.
 */
@Transactional(readOnly = true)
public Owner loadOwner(int id) throws DataAccessException {
	Owner owner;
	try {
		owner = this.simpleJdbcTemplate.queryForObject(
				"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id=?",
				ParameterizedBeanPropertyRowMapper.newInstance(Owner.class),
				id);
	}
	catch (EmptyResultDataAccessException ex) {
		throw new ObjectRetrievalFailureException(Owner.class, new Integer(id));
	}
	loadPetsAndVisits(owner);
	return owner;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:21,代码来源:SimpleJdbcClinic.java

示例4: loadPet

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
@Transactional(readOnly = true)
public Pet loadPet(int id) throws DataAccessException {
	JdbcPet pet;
	try {
		pet = this.simpleJdbcTemplate.queryForObject(
				"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=?",
				new JdbcPetRowMapper(),
				id);
	}
	catch (EmptyResultDataAccessException ex) {
		throw new ObjectRetrievalFailureException(Pet.class, new Integer(id));
	}
	Owner owner = loadOwner(pet.getOwnerId());
	owner.addPet(pet);
	pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
	loadVisits(pet);
	return pet;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:19,代码来源:SimpleJdbcClinic.java

示例5: findBySinglePrimaryKey

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.dao.BusinessObjectDao#findBySinglePrimaryKey(java.lang.Class, java.lang.Object)
 */
public <T extends BusinessObject> T findBySinglePrimaryKey(Class<T> clazz, Object primaryKey) {
	if (primaryKey.getClass().getName().startsWith("java.lang.")
               || primaryKey.getClass().getName().startsWith("java.sql.")
               || primaryKey.getClass().getName().startsWith("java.math.")
               || primaryKey.getClass().getName().startsWith("java.util.")) {
		try {
			return (T) getPersistenceBrokerTemplate().getObjectById(clazz, primaryKey);
		} catch (  ObjectRetrievalFailureException ex  ) {
    		// it doesn't exist, just return null
			return null;
		}
	} else {
		Criteria criteria = buildCriteria(clazz, primaryKey);

        return (T) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(clazz, criteria));
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:21,代码来源:BusinessObjectDaoOjb.java

示例6: loadUserByUsername

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * DO NOT CALL THIS METHOD IN LONG RUNNING SESSIONS OR CONVERSATIONS A
 * THROWN UsernameNotFoundException WILL RENDER THE CONVERSATION UNUSABLE.
 *
 * @param username
 *            Set the username
 * @return the userdetails of the user
 */
@Transactional(readOnly = true)
public final UserDetails loadUserByUsername(final String username) {
 try {
	 Assert.hasText(username);
 } catch (IllegalArgumentException iae) {
	 throw new UsernameNotFoundException(username, iae);
 }
 try {
	 User user = dao.load(username);
	 userCache.putUserInCache(user);
	 return user;
 } catch (ObjectRetrievalFailureException orfe) {
	 throw new UsernameNotFoundException(username, orfe);
 } catch (NonUniqueResultException nure) {
	 throw new IncorrectResultSizeDataAccessException(
			 "More than one user found with name '" + username + "'", 1);
 }
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:27,代码来源:UserServiceImpl.java

示例7: findById

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits}
 * for the corresponding owner, if not already loaded.
 */
@Override
public Owner findById(int id) throws DataAccessException {
    Owner owner;
    try {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        owner = this.namedParameterJdbcTemplate.queryForObject(
                "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
                params,
                BeanPropertyRowMapper.newInstance(Owner.class)
        );
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Owner.class, id);
    }
    loadPetsAndVisits(owner);
    return owner;
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:22,代码来源:JdbcOwnerRepositoryImpl.java

示例8: findById

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
@Override
public Pet findById(int id) throws DataAccessException {
    JdbcPet pet;
    try {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        pet = this.namedParameterJdbcTemplate.queryForObject(
                "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
                params,
                new JdbcPetRowMapper());
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Pet.class, new Integer(id));
    }
    Owner owner = this.ownerRepository.findById(pet.getOwnerId());
    owner.addPet(pet);
    pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId()));

    List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
    for (Visit visit : visits) {
        pet.addVisit(visit);
    }
    return pet;
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:24,代码来源:JdbcPetRepositoryImpl.java

示例9: findById

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits}
 * for the corresponding owner, if not already loaded.
 */
@Override
public Owner findById(int id) throws DataAccessException {
    Owner owner;
    try {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        owner = this.namedParameterJdbcTemplate.queryForObject(
                "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
                params,
                BeanPropertyRowMapper.newInstance(Owner.class)
        );
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Owner.class, id);
    }
    loadPetsAndVisits(owner);
    return owner;
}
 
开发者ID:YoannBuch,项目名称:DependencyInjectionAgent,代码行数:22,代码来源:JdbcOwnerRepositoryImpl.java

示例10: findById

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
@Override
public Pet findById(int id) throws DataAccessException {
    JdbcPet pet;
    try {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        pet = this.namedParameterJdbcTemplate.queryForObject(
                "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
                params,
                new JdbcPetRowMapper());
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Pet.class, id);
    }
    Owner owner = this.ownerRepository.findById(pet.getOwnerId());
    owner.addPet(pet);
    pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId()));

    List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
    for (Visit visit : visits) {
        pet.addVisit(visit);
    }
    return pet;
}
 
开发者ID:YoannBuch,项目名称:DependencyInjectionAgent,代码行数:24,代码来源:JdbcPetRepositoryImpl.java

示例11: findById

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits}
 * for the corresponding owner, if not already loaded.
 */
@Override
public Owner findById(int id) throws DataAccessException {
    Owner owner;
    try {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        owner = this.namedParameterJdbcTemplate.queryForObject(
                "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
                params,
                ParameterizedBeanPropertyRowMapper.newInstance(Owner.class)
        );
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Owner.class, id);
    }
    loadPetsAndVisits(owner);
    return owner;
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:22,代码来源:JdbcOwnerRepositoryImpl.java

示例12: getResourcesForNode

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/** {@inheritDoc} */
public List<OnmsResource> getResourcesForNode(final int nodeId) {
	final LinkedList<OnmsResource> resources = new LinkedList<OnmsResource>();
    
	final OnmsNode node = m_nodeDao.get(nodeId);
    if (node == null) {
        throw new ObjectRetrievalFailureException(OnmsNode.class, nodeId, "Could not find node for node Id " + nodeId, null);
    }
    
    for (final OnmsIpInterface i : node.getIpInterfaces()) {
        String ipAddr = InetAddressUtils.str(i.getIpAddress());

        final File iface = getInterfaceDirectory(ipAddr, false);
        
        if (iface.isDirectory()) {
            resources.add(createResource(i));
        }
    }

    return resources;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:ResponseTimeResourceType.java

示例13: getNodeEntityResource

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * <p>getNodeEntityResource</p>
 *
 * @param resource a {@link java.lang.String} object.
 * @return a {@link org.opennms.netmgt.model.OnmsResource} object.
 */
protected OnmsResource getNodeEntityResource(String resource) {
    int nodeId;
    try {
        nodeId = Integer.parseInt(resource);
    } catch (NumberFormatException e) {
        throw new ObjectRetrievalFailureException(OnmsNode.class, resource, "Top-level resource of resource type node is not numeric: " + resource, null);
    }
    
    OnmsNode node = m_nodeDao.get(nodeId);
    if (node == null) {
        throw new ObjectRetrievalFailureException(OnmsNode.class, resource, "Top-level resource of resource type node could not be found: " + resource, null);
    }

    OnmsResource onmsResource = getResourceForNode(node);

    return onmsResource;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:DefaultResourceDao.java

示例14: getForeignSourceNodeEntityResource

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * <p>getForeignSourceNodeEntityResource</p>
 *
 * @param resource a {@link java.lang.String} object.
 * @return a {@link org.opennms.netmgt.model.OnmsResource} object.
 */
protected OnmsResource getForeignSourceNodeEntityResource(String resource) {
    
    File idDir = new File(getRrdDirectory(), SNMP_DIRECTORY + File.separator + ResourceTypeUtils.getRelativeNodeSourceDirectory(resource).toString());
    if (idDir.isDirectory() && RrdFileConstants.NODESOURCE_DIRECTORY_FILTER.accept(idDir)) {
        return m_nodeSourceResourceType.createChildResource(resource);
    } else {
       log().debug("resource " + resource + " not found by foreign source/foreignId. Trying as a node resource instead...");
       String[] ident = resource.split(":");
       OnmsNode node = m_nodeDao.findByForeignId(ident[0], ident[1]);
       if (node == null) {
            throw new ObjectRetrievalFailureException(OnmsNode.class, resource, "Top-level resource of resource type node could not be found: " + resource, null);
       }
       
       OnmsResource onmsResource = getResourceForNode(node);
       
       return onmsResource;
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:DefaultResourceDao.java

示例15: testPrefabGraphPartlyBorkedConfig

import org.springframework.orm.ObjectRetrievalFailureException; //导入依赖的package包/类
/**
 * Test that we can load a partly borked config file (i.e. if one graph is incorrectly specified,
 * we load as many of the rest as we can).
 * The borked'ness we can tolerate does not include poor double quoting which confuses the underlying
 * Java properties parser, but misspelled property names should only affect the graph in question.
 * 
 * NB: It should still complain with an Error log.  Should there be an event as well?
 * @throws Exception
 */
public void testPrefabGraphPartlyBorkedConfig() throws Exception {
    //We're expecting an ERROR log, and will be most disappointed if
    // we don't get it.  Turn off the default check in runTest
    testSpecificLoggingTest = true;
    
    PropertiesGraphDao dao = createPropertiesGraphDao(s_emptyMap, s_emptyMap);
    dao.loadProperties("foo", new ByteArrayInputStream(s_partlyBorkedPrefab.getBytes("UTF-8")));
    
    //We expect to be able to get a mib2.HCbits, and a mib2.discards, but no mib2.bits 
    try {
        PrefabGraph mib2bits = dao.getPrefabGraph("mib2.bits");
        fail("Should have thrown an ObjectRetrievalFailureException retrieving graph "+mib2bits);
    } catch (ObjectRetrievalFailureException e) {
        
    }
    PrefabGraph mib2HCbits = dao.getPrefabGraph("mib2.HCbits");
    assertNotNull(mib2HCbits);
    PrefabGraph mib2Discards = dao.getPrefabGraph("mib2.discards");
    assertNotNull(mib2Discards);
    
    //There should have been an error log about the  failure 
    MockLogAppender.assertLogAtLevel(Level.ERROR); 

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:34,代码来源:PropertiesGraphDaoTest.java


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