Package org.springframework.samples.petclinic

Examples of org.springframework.samples.petclinic.Owner


        dataBinder.setDisallowedFields(new String[] {"id"});
    }

    @RequestMapping(method = RequestMethod.GET)
  public String setupForm(Model model) {
    Owner owner = new Owner();
    model.addAttribute(owner);
    return "ownerForm";
  }
View Full Code Here


        dataBinder.setDisallowedFields(new String[] {"id"});
    }

  @RequestMapping(method = RequestMethod.GET)
  public  String setupForm(Model model) {
    model.addAttribute("owner", new Owner());
    return "findOwners";
  }
View Full Code Here

        dataBinder.setDisallowedFields(new String[] {"id"});
    }

    @RequestMapping(method = RequestMethod.GET)
  public String setupForm(@RequestParam("ownerId") int ownerId, Model model) {
    Owner owner = this.clinic.loadOwner(ownerId);
    Pet pet = new Pet();
    owner.addPet(pet);
    model.addAttribute("pet", pet);
    return "petForm";
  }
View Full Code Here

        dataBinder.setDisallowedFields(new String[] {"id"});
    }

  @RequestMapping(method = RequestMethod.GET)
  public String setupForm(@RequestParam("ownerId") int ownerId, Model model) {
    Owner owner = this.clinic.loadOwner(ownerId);
    model.addAttribute(owner);
    return "ownerForm";
  }
View Full Code Here

   * 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);
View Full Code Here

          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;
  }
View Full Code Here

  }

  public void storeOwner(Owner owner) {
    // Consider returning the persistent object here, for exposing
    // a newly assigned id using any persistence provider...
    Owner merged = this.em.merge(owner);
    this.em.flush();
    owner.setId(merged.getId());
  }
View Full Code Here

    owners = this.clinic.findOwners("Daviss");
    assertEquals(0, owners.size());
  }

  public void testLoadOwner() {
    Owner o1 = this.clinic.loadOwner(1);
    assertTrue(o1.getLastName().startsWith("Franklin"));
    Owner o10 = this.clinic.loadOwner(10);
    assertEquals("Carlos", o10.getFirstName());

    // Check lazy loading, by ending the transaction
    endTransaction();

    // Now Owners are "disconnected" from the data store.
View Full Code Here

  }

  public void testInsertOwner() {
    Collection<Owner> owners = this.clinic.findOwners("Schultz");
    int found = owners.size();
    Owner owner = new Owner();
    owner.setLastName("Schultz");
    this.clinic.storeOwner(owner);
    // assertTrue(!owner.isNew()); -- NOT TRUE FOR TOPLINK (before commit)
    owners = this.clinic.findOwners("Schultz");
    assertEquals(found + 1, owners.size());
  }
View Full Code Here

    owners = this.clinic.findOwners("Schultz");
    assertEquals(found + 1, owners.size());
  }

  public void testUpdateOwner() throws Exception {
    Owner o1 = this.clinic.loadOwner(1);
    String old = o1.getLastName();
    o1.setLastName(old + "X");
    this.clinic.storeOwner(o1);
    o1 = this.clinic.loadOwner(1);
    assertEquals(old + "X", o1.getLastName());
  }
View Full Code Here

TOP

Related Classes of org.springframework.samples.petclinic.Owner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.