diff --git a/src/main/java/org/springframework/samples/petclinic/Vet.java b/src/main/java/org/springframework/samples/petclinic/Vet.java index 5ef56fe8e2ca5787cc284006a0c98c20a0305011..744288bfeba264d722d4d047b0d160e0522101f8 100644 --- a/src/main/java/org/springframework/samples/petclinic/Vet.java +++ b/src/main/java/org/springframework/samples/petclinic/Vet.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Set; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; @@ -27,7 +28,8 @@ import org.springframework.beans.support.PropertyComparator; @Entity @Table(name="vets") public class Vet extends Person { - @ManyToMany @JoinTable (name="vet_specialties",joinColumns = @JoinColumn(name = "vet_id"), + @ManyToMany(fetch=FetchType.EAGER) + @JoinTable (name="vet_specialties",joinColumns = @JoinColumn(name = "vet_id"), inverseJoinColumns= @JoinColumn(name = "specialty_id")) private Set<Specialty> specialties; diff --git a/src/main/java/org/springframework/samples/petclinic/web/VetController.java b/src/main/java/org/springframework/samples/petclinic/web/VetController.java index 07bcaaa8492d1c4e96c9cc1617ba7ab887f9a76e..50cefc7d3c8aae29b446a73c85149bfac302bf9f 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/VetController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/VetController.java @@ -44,7 +44,7 @@ public class VetController { Vets vets = new Vets(); vets.getVetList().addAll(this.clinicService.findVets()); model.addAttribute("vets", vets); - return "vets/vetsList"; + return "vets/vetList"; } diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetsList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp similarity index 90% rename from src/main/webapp/WEB-INF/jsp/vets/vetsList.jsp rename to src/main/webapp/WEB-INF/jsp/vets/vetList.jsp index 057454ab7355f66393b55f10a1ffa66de69e8a69..fc68b56d9d31395a8fb9844e4b24baa6002c339f 100644 --- a/src/main/webapp/WEB-INF/jsp/vets/vetsList.jsp +++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp @@ -24,10 +24,10 @@ <tbody> <c:forEach var="vet" items="${vets.vetList}"> <tr> - <td>${vet.firstName} ${vet.lastName}</td> + <td><c:out value="${vet.firstName} ${vet.lastName}" /></td> <td> <c:forEach var="specialty" items="${vet.specialties}"> - ${specialty.name} + <c:out value="${specialty.name}" /> </c:forEach> <c:if test="${vet.nrOfSpecialties == 0}">none</c:if> </td> diff --git a/src/main/webapp/WEB-INF/mvc-view-config.xml b/src/main/webapp/WEB-INF/mvc-view-config.xml index a917998716f603bb2c3fc48a26f305248533119a..94ca95fa0f630521a68e6b756343fdf890b14803 100644 --- a/src/main/webapp/WEB-INF/mvc-view-config.xml +++ b/src/main/webapp/WEB-INF/mvc-view-config.xml @@ -56,7 +56,7 @@ <!-- - The AtomView rendering a Atom feed of the visits --> <bean id="visitList" class="org.springframework.samples.petclinic.web.VisitsAtomView"/> - <bean id="vets/vetsList" class="org.springframework.web.servlet.view.xml.MarshallingView"> + <bean id="vets/vetList" class="org.springframework.web.servlet.view.xml.MarshallingView"> <property name="marshaller" ref="marshaller"/> </bean>