• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Visit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: findById

import org.springframework.samples.petclinic.model.Visit; //导入依赖的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


示例2: findByPetId

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
public List<Visit> findByPetId(Integer petId) {
    Map<String, Object> params = new HashMap<>();
    params.put("id", petId);
    JdbcPet pet = this.jdbcTemplate.queryForObject(
            "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
            params,
            new JdbcPetRowMapper());

    List<Visit> visits = this.jdbcTemplate.query(
        "SELECT id as visit_id, visit_date, description FROM visits WHERE pet_id=:id",
        params, new JdbcVisitRowMapper());

    for (Visit visit: visits) {
        visit.setPet(pet);
    }

    return visits;
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:20,代码来源:JdbcVisitRepositoryImpl.java


示例3: findByPetId

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
public List<Visit> findByPetId(Integer petId) {
    final List<Visit> visits = this.jdbcTemplate.query(
            "SELECT id, visit_date, description FROM visits WHERE pet_id=?",
            new BeanPropertyRowMapper<Visit>() {
                @Override
                public Visit mapRow(ResultSet rs, int row) throws SQLException {
                    Visit visit = new Visit();
                    visit.setId(rs.getInt("id"));
                    Date visitDate = rs.getDate("visit_date");
                    visit.setDate(new DateTime(visitDate));
                    visit.setDescription(rs.getString("description"));
                    return visit;
                }
            },
            petId);
    return visits;
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:19,代码来源:JdbcVisitRepositoryImpl.java


示例4: loadPetsAndVisits

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
public void loadPetsAndVisits(final Owner owner) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("id", owner.getId().intValue());
    final List<JdbcPet> pets = this.namedParameterJdbcTemplate.query(
            "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE owner_id=:id",
            params,
            new JdbcPetRowMapper()
    );
    for (JdbcPet pet : pets) {
        owner.addPet(pet);
        pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
        List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
        for (Visit visit : visits) {
            pet.addVisit(visit);
        }
    }
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:18,代码来源:JdbcOwnerRepositoryImpl.java


示例5: findById

import org.springframework.samples.petclinic.model.Visit; //导入依赖的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


示例6: findById

import org.springframework.samples.petclinic.model.Visit; //导入依赖的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


示例7: findByPetId

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
public List<Visit> findByPetId(Integer petId) {
    final List<Visit> visits = this.jdbcTemplate.query(
            "SELECT id, visit_date, description FROM visits WHERE pet_id=?",
            new ParameterizedRowMapper<Visit>() {
                @Override
                public Visit mapRow(ResultSet rs, int row) throws SQLException {
                    Visit visit = new Visit();
                    visit.setId(rs.getInt("id"));
                    Date visitDate = rs.getDate("visit_date");
                    visit.setDate(new DateTime(visitDate));
                    visit.setDescription(rs.getString("description"));
                    return visit;
                }
            },
            petId);
    return visits;
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:19,代码来源:JdbcVisitRepositoryImpl.java


示例8: getOwnerVisits

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@RequestMapping(value = "/owner/{ownerId}/getVisits", method = RequestMethod.GET)
public ResponseEntity<List<Visit>> getOwnerVisits(@PathVariable int ownerId){
    List<Pet> petList = this.owners.findById(ownerId).getPets();
    List<Visit> visitList = new ArrayList<Visit>();
    petList.forEach(pet -> visitList.addAll(pet.getVisits()));
    return new ResponseEntity<List<Visit>>(visitList, HttpStatus.OK);
}
 
开发者ID:awslabs,项目名称:amazon-ecs-java-microservices,代码行数:8,代码来源:OwnerController.java


示例9: getOwnerVisits

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@RequestMapping(value = "/owner/{ownerId}/getVisits", method = RequestMethod.GET)
public ResponseEntity<List<Visit>> getOwnerVisits(@PathVariable int ownerId){
    List<Pet> petList = this.owners.findById(ownerId).getPets();
    List<Visit> visitList = new ArrayList<Visit>();
    petList.forEach(pet -> {
        logger.info(getPetVisits(pet.getId()).toString());
        visitList.addAll(getPetVisits(pet.getId()));
    });
    return new ResponseEntity<List<Visit>>(visitList, HttpStatus.OK);
}
 
开发者ID:awslabs,项目名称:amazon-ecs-java-microservices,代码行数:11,代码来源:OwnerController.java


示例10: getPetVisits

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
private List<Visit> getPetVisits(int petId){
    List<Visit> visitList = new ArrayList<Visit>();
    RestTemplate restTemplate = new RestTemplate();
    Pet pet = restTemplate.getForObject("http://"+serviceEndpoint+"/pet/"+petId, Pet.class);
    logger.info(pet.getVisits().toString());
    return pet.getVisits();
}
 
开发者ID:awslabs,项目名称:amazon-ecs-java-microservices,代码行数:8,代码来源:OwnerController.java


示例11: processNewVisitForm

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new", method = RequestMethod.POST)
public String processNewVisitForm(@Valid Visit visit, BindingResult result) {
    if (result.hasErrors()) {
        return "pets/createOrUpdateVisitForm";
    } else {
        this.clinicService.saveVisit(visit);
        return "redirect:/owners/{ownerId}";
    }
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:10,代码来源:VisitController.java


示例12: save

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
public void save(Visit visit) {
    if (visit.getId() == null) {
        this.em.persist(visit);
    } else {
        this.em.merge(visit);
    }
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:9,代码来源:JpaVisitRepositoryImpl.java


示例13: findByPetId

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public List<Visit> findByPetId(Integer petId) {
    Query query = this.em.createQuery("SELECT visit FROM Visit v where v.pets.id= :id");
    query.setParameter("id", petId);
    return query.getResultList();
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:8,代码来源:JpaVisitRepositoryImpl.java


示例14: mapRow

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
public Visit mapRow(ResultSet rs, int row) throws SQLException {
    Visit visit = new Visit();
    visit.setId(rs.getInt("visit_id"));
    Date visitDate = rs.getDate("visit_date");
    visit.setDate(new LocalDate(visitDate));
    visit.setDescription(rs.getString("description"));
    return visit;
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:10,代码来源:JdbcVisitRowMapper.java


示例15: save

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
public void save(Visit visit) throws DataAccessException {
    if (visit.isNew()) {
        Number newKey = this.insertVisit.executeAndReturnKey(
            createVisitParameterSource(visit));
        visit.setId(newKey.intValue());
    } else {
        throw new UnsupportedOperationException("Visit update not supported");
    }
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:11,代码来源:JdbcVisitRepositoryImpl.java


示例16: createVisitParameterSource

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
/**
 * Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Visit} instance.
 */
private MapSqlParameterSource createVisitParameterSource(Visit visit) {
    return new MapSqlParameterSource()
        .addValue("id", visit.getId())
        .addValue("visit_date", visit.getDate().toDate())
        .addValue("description", visit.getDescription())
        .addValue("pet_id", visit.getPet().getId());
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:11,代码来源:JdbcVisitRepositoryImpl.java


示例17: shouldAddNewVisitForPet

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Test
@Transactional
public void shouldAddNewVisitForPet() {
    Pet pet7 = this.clinicService.findPetById(7);
    int found = pet7.getVisits().size();
    Visit visit = new Visit();
    pet7.addVisit(visit);
    visit.setDescription("test");
    this.clinicService.saveVisit(visit);
    this.clinicService.savePet(pet7);

    pet7 = this.clinicService.findPetById(7);
    assertThat(pet7.getVisits().size()).isEqualTo(found + 1);
    assertThat(visit.getId()).isNotNull();
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:16,代码来源:AbstractClinicServiceTests.java


示例18: findByPetId

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public List<Visit> findByPetId(Integer petId) {
    Query query = this.em.createQuery("SELECT v FROM Visit v where v.pet.id= :id");
    query.setParameter("id", petId);
    return query.getResultList();
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:8,代码来源:JpaVisitRepositoryImpl.java


示例19: mapRow

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
@Override
public Visit mapRow(ResultSet rs, int row) throws SQLException {
    Visit visit = new Visit();
    visit.setId(rs.getInt("visit_id"));
    Date visitDate = rs.getDate("visit_date");
    visit.setDate(new Date(visitDate.getTime()));
    visit.setDescription(rs.getString("description"));
    return visit;
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:10,代码来源:JdbcVisitRowMapper.java


示例20: createVisitParameterSource

import org.springframework.samples.petclinic.model.Visit; //导入依赖的package包/类
/**
 * Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Visit} instance.
 */
private MapSqlParameterSource createVisitParameterSource(Visit visit) {
    return new MapSqlParameterSource()
        .addValue("id", visit.getId())
        .addValue("visit_date", visit.getDate())
        .addValue("description", visit.getDescription())
        .addValue("pet_id", visit.getPet().getId());
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:11,代码来源:JdbcVisitRepositoryImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RepairMessage类代码示例发布时间:2022-05-23
下一篇:
Java X509CRLObject类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap