List of usage examples for org.springframework.orm ObjectRetrievalFailureException ObjectRetrievalFailureException
public ObjectRetrievalFailureException(String persistentClassName, Object identifier)
From source file:com.branded.holdings.qpc.repository.jdbc.JdbcTopicRepositoryImpl.java
@Override public Topic findById(int id) throws DataAccessException { JdbcTopic topic;//from w w w . j av a 2 s. com try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id", id); topic = this.namedParameterJdbcTemplate.queryForObject( "SELECT id, description, emotiontype_id, weight FROM topic WHERE id=:id", params, new JdbcTopicRowMapper()); } catch (EmptyResultDataAccessException ex) { throw new ObjectRetrievalFailureException(Pet.class, new Integer(id)); } topic.setType(EntityUtils.getById(findEmotionTypes(), EmotionType.class, topic.getTypeId())); return topic; }
From source file:net.softforlife.klich.service.impl.UserServiceImpl.java
@Transactional(readOnly = true) public Tuser getUserById(int userId) { Tuser user = getUserDAO().getUserById(userId); if (user == null) { throw new ObjectRetrievalFailureException(Tuser.class, userId); }//from www . j a va 2s . co m /* * String realPassword = * securityService.decryptText(user.getRecovery()); if ( realPassword != * null && realPassword.length() > 0){ user.setPassword(realPassword); } */ return user; }
From source file:com.catt.mobile.repository.jdbc.JdbcAccountRepositoryImpl.java
@Override public Account findById(int id) throws DataAccessException { Account account;//from w w w . ja v a 2 s . co m try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id", id); account = this.namedParameterJdbcTemplate.queryForObject( "SELECT id, name, address, telephone,email FROM account WHERE id= :id", params, ParameterizedBeanPropertyRowMapper.newInstance(Account.class)); } catch (EmptyResultDataAccessException ex) { throw new ObjectRetrievalFailureException(Account.class, id); } return account; }
From source file:org.openhie.openempi.dao.hibernate.GenericDaoHibernate.java
/** * {@inheritDoc}//from ww w. jav a 2 s.co m */ @SuppressWarnings("unchecked") public T get(PK id) { T entity = (T) super.getHibernateTemplate().get(this.persistentClass, id); if (entity == null) { log.warn("Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found..."); throw new ObjectRetrievalFailureException(this.persistentClass, id); } return entity; }
From source file:com.rambird.miles.repository.jdbc.JdbcCatgRepositoryImpl.java
/** * 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. *///from w w w . j av a 2s .c o m @Override public Category findById(int id) throws DataAccessException { Category category; try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id", id); category = this.namedParameterJdbcTemplate.queryForObject( "SELECT catgid, catg, catg_label, user_name, home, catg_rank FROM category WHERE catgid= :id", params, ParameterizedBeanPropertyRowMapper.newInstance(Category.class)); } catch (EmptyResultDataAccessException ex) { throw new ObjectRetrievalFailureException(Category.class, id); } return category; }
From source file:com.pet.demo.repository.jdbc.JdbcPetRepositoryImpl.java
public Pet findById(int id) throws DataAccessException { JdbcPet pet;/*from w w w. java 2s . c o m*/ 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; }
From source file:com.branded.holdings.qpc.repository.jdbc.JdbcPetRepositoryImpl.java
@Override public Pet findById(int id) throws DataAccessException { JdbcPet pet;// w ww. ja v a 2 s .c o m 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; }
From source file:com.rambird.miles.repository.jdbc.JdbcMileRepositoryImpl.java
/** * 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. *///from w w w . ja v a 2 s .c om @Override public MyMile findById(int id) throws DataAccessException { MyMile mile; try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id", id); mile = this.namedParameterJdbcTemplate.queryForObject(SELECT_QUERY + " WHERE mileid= :id", params, ParameterizedBeanPropertyRowMapper.newInstance(MyMile.class)); } catch (EmptyResultDataAccessException ex) { throw new ObjectRetrievalFailureException(MyMile.class, id); } return mile; }
From source file:com.painiu.core.dao.hibernate.PhotoDAOHibernate.java
public Photo getPhoto(String id) { Photo photo = (Photo) getHibernateTemplate().get(Photo.class, id); if (photo == null) { if (log.isWarnEnabled()) { log.warn("uh, oh, photo[" + id + "] not found..."); }//from w ww . j a va 2s. c om throw new ObjectRetrievalFailureException(Photo.class, id); } return photo; }
From source file:com.pet.demo.repository.jdbc.JdbcOwnerRepositoryImpl.java
/** * 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. *//*from w w w .j av a 2 s .c o m*/ 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; }