Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
package org.springframework.samples.petclinic.owner;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.style.ToStringCreator;
import java.util.List;import org.springframework.core.style.ToStringCreator;
import org.springframework.samples.petclinic.model.Person;
import org.springframework.util.Assert;import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
Expand Down Expand Up @@ -49,9 +47,7 @@

@Column(name = "city")
@NotBlank
private String city;

@Column(name = "telephone")
private String city;@Column(name = "telephone")
@NotBlank
@Digits(fraction = 0, integer = 10)
private String telephone;
Expand Down Expand Up @@ -88,9 +84,7 @@ public void setTelephone(String telephone) {

public List<Pet> getPets() {
return this.pets;
}

public void addPet(Pet pet) {
}public void addPet(Pet pet) {
if (pet.isNew()) {
getPets().add(pet);
}
Expand All @@ -101,9 +95,7 @@ public void addPet(Pet pet) {
*/
public Pet getPet(String name) {
return getPet(name, false);
}

/**
}/**
* Return the Pet with the given id, or null if none found for this Owner.
* @param id to test
* @return a pet if pet id is already in use
Expand Down Expand Up @@ -134,9 +126,7 @@ public Pet getPet(String name, boolean ignoreNew) {
}
}
return null;
}

@Override
}@Override
public String toString() {
return new ToStringCreator(this).append("id", this.getId())
.append("new", this.isNew())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;

import java.util.List;import org.springframework.data.domain.Page;
package org.springframework.samples.petclinic.owner;import java.util.List;import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
Expand All @@ -32,9 +30,7 @@
* @author Juergen Hoeller
* @author Sam Brannen
* @author Michael Isvy
*/public interface OwnerRepository extends Repository<Owner, Integer> {

/**
*/public interface OwnerRepository extends Repository<Owner, Integer> {/**
* Retrieve all {@link PetType}s from the data store.
* @return a Collection of {@link PetType}s.
*/
Expand All @@ -52,9 +48,7 @@

@Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName% ")
@Transactional(readOnly = true)
Page<Owner> findByLastName(@Param("lastName") String lastName, Pageable pageable);

/**
Page<Owner> findByLastName(@Param("lastName") String lastName, Pageable pageable);/**
* Retrieve all {@link Owner}s from the data store with their pets.
* @return a Collection of {@link Owner}s.
*/
Expand All @@ -77,9 +71,7 @@

@Query("SELECT SIZE(o.pets) FROM Owner o WHERE o.id = :id")
@Transactional(readOnly = true)
int countPets(int id);

/**
int countPets(int id);/**
* Returns all the owners from data store
**/
@Query("SELECT owner FROM Owner owner left join fetch owner.pets")
Expand Down