I have the following Spring MVC controller that uses both a repository and an active record. I systematically get the following exception:
Note that the line does exists in database!!Code:Caused by: javax.persistence.EntityNotFoundException: Unable to find trc.suivi.domain.Destinataire with id 892 at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:137) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:233) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090) at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630) at org.hibernate.type.EntityType.resolve(EntityType.java:438) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982) at org.hibernate.loader.Loader.doQuery(Loader.java:857) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274) at org.hibernate.loader.Loader.doList(Loader.java:2542) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276) at org.hibernate.loader.Loader.list(Loader.java:2271) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:459) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:365) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246) ... 78 more
Here is my controller code:
Code:@RequestMapping("/plis") @Controller @RooWebScaffold(path = "plis", formBackingObject = Pli.class) @RooWebFinder public class PliController { @Autowired private PliRepository pliRepository; @RequestMapping(params = { "find=ByMultiField", "form" }, method = RequestMethod.GET) public String findPlisByMultiFieldForm(Model uiModel) { populateMultiFieldForm(uiModel); return "plis/findPlisByMultiField"; } @RequestMapping(params = "find=ByMultiField", method = RequestMethod.GET) public String findPlisByMultiField(@RequestParam("identifiant") String identifiant, Model uiModel) { uiModel.addAttribute("plis", pliRepository.findPlisByMultiFieldQuery(identifiant, null, false, false, null, false, null, null).getResultList());//REPOSITORY USAGE return "plis/list"; } void populateMultiFieldForm(Model uiModel) { uiModel.addAttribute("pli_datereception_date_format", DateTimeFormat.patternForStyle("M-", LocaleContextHolder.getLocale())); uiModel.addAttribute("conteneurnums", ConteneurNum.findAllConteneurNums());//ACTIVE RECORD USAGE uiModel.addAttribute("statutplis", Arrays.asList(StatutPli.values())); } }


Reply With Quote
