Commit b7d4b323 authored by Matija Obreza's avatar Matija Obreza
Browse files

Crop#cropRules not eagerly loaded

parent ca541237
...@@ -26,7 +26,6 @@ import java.util.Map; ...@@ -26,7 +26,6 @@ import java.util.Map;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
...@@ -72,7 +71,7 @@ public class Crop extends GlobalVersionedAuditedModel implements AclAwareModel { ...@@ -72,7 +71,7 @@ public class Crop extends GlobalVersionedAuditedModel implements AclAwareModel {
* Rules * Rules
*/ */
@JsonIgnore @JsonIgnore
@OneToMany(mappedBy = "crop", fetch = FetchType.EAGER, cascade = {}, orphanRemoval = true) @OneToMany(mappedBy = "crop", cascade = {}, orphanRemoval = true)
private List<CropRule> cropRules; private List<CropRule> cropRules;
@Transient @Transient
......
...@@ -59,6 +59,7 @@ public class CropController extends BaseController { ...@@ -59,6 +59,7 @@ public class CropController extends BaseController {
throw new ResourceNotFoundException(); throw new ResourceNotFoundException();
} }
model.addAttribute("crop", crop); model.addAttribute("crop", crop);
model.addAttribute("cropRules", cropService.getCropRules(crop));
model.addAttribute("cropTaxonomies", cropService.getCropTaxonomies(crop, new PageRequest(0, 20, new Sort("taxonomy.genus", "taxonomy.species")))); model.addAttribute("cropTaxonomies", cropService.getCropTaxonomies(crop, new PageRequest(0, 20, new Sort("taxonomy.genus", "taxonomy.species"))));
return "/crop/index"; return "/crop/index";
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<h4><spring:message code="crop.taxonomy-rules" /></h4> <h4><spring:message code="crop.taxonomy-rules" /></h4>
<ul class="funny-list"> <ul class="funny-list">
<c:forEach items="${crop.cropRules}" var="rule"> <c:forEach items="${cropRules}" var="rule">
<li class="${rule.included ? '' : 'excluded'}" /><b>${rule.included ? '+' : '-'}</b> <c:out value="${rule.genus}" /> <c:out value="${rule.species eq null ? '*' : rule.species}" /></li> <li class="${rule.included ? '' : 'excluded'}" /><b>${rule.included ? '+' : '-'}</b> <c:out value="${rule.genus}" /> <c:out value="${rule.species eq null ? '*' : rule.species}" /></li>
</c:forEach> </c:forEach>
</ul> </ul>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment