Configure caching properly to avoid error in vets

This commit is contained in:
Dave Syer 2017-01-08 15:45:20 +00:00
parent 0f840cd50b
commit 80269539e2
5 changed files with 42 additions and 29 deletions

View file

@ -15,6 +15,8 @@
*/
package org.springframework.samples.petclinic.vet;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -27,6 +29,6 @@ import org.springframework.samples.petclinic.model.NamedEntity;
*/
@Entity
@Table(name = "specialties")
public class Specialty extends NamedEntity {
public class Specialty extends NamedEntity implements Serializable {
}

View file

@ -15,6 +15,7 @@
*/
package org.springframework.samples.petclinic.vet;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@ -43,11 +44,10 @@ import org.springframework.samples.petclinic.model.Person;
*/
@Entity
@Table(name = "vets")
public class Vet extends Person {
public class Vet extends Person implements Serializable {
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"),
inverseJoinColumns = @JoinColumn(name = "specialty_id"))
@JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
private Set<Specialty> specialties;
protected Set<Specialty> getSpecialtiesInternal() {
@ -64,7 +64,8 @@ public class Vet extends Person {
@XmlElement
public List<Specialty> getSpecialties() {
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
PropertyComparator.sort(sortedSpecs, new MutableSortDefinition("name", true, true));
PropertyComparator.sort(sortedSpecs,
new MutableSortDefinition("name", true, true));
return Collections.unmodifiableList(sortedSpecs);
}