I have added a finder
finder add --finderName findConfigurationsByConfigurationNameLikeOrConfigu rationSectionLikeOrConfigurationValueLike
Where the entity Configuration has three string fields ConfigurationValue, ConfigurationName and ConfigurationSection.
The problem I have is that the find form has all the fields but you cannot enter a value in just one as it throws
The entity Controller.aj hasCode:Required String parameter 'configurationName' is not present org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.raiseMissingParameterException(AnnotationMethodHandlerAdapter.java:717) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:501) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:340) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
I found the Controller_Finder.aj and pushed that in.Code:@RequestMapping(params = "find=ByConfigurationNameLikeOrConfigurationSectionLikeOrConfigurationValueLike", method = RequestMethod.GET) public String ConfigurationController.findConfigurationsByConfigurationNameLikeOrConfigurationSectionLikeOrConfigurationValueLike(@RequestParam("configurationName") String ConfigurationName, @RequestParam("configurationSection") String ConfigurationSection, @RequestParam("configurationValue") String ConfigurationValue, Model uiModel) { uiModel.addAttribute("configurations", Configuration.findConfigurationsByConfigurationNameLikeOrConfigurationSectionLikeOrConfigurationValueLike(ConfigurationName, ConfigurationSection, ConfigurationValue).getResultList()); return "configurations/list"; }
I modified the applicable find method in the Controller.
to add the @RequestParam(required = false,Code:@RequestMapping(params = "find=ByConfigurationNameLikeOrConfigurationSectionLikeOrConfigurationValueLike", method = RequestMethod.GET) public String findConfigurationsByConfigurationNameLikeOrConfigurationSectionLikeOrConfigurationValueLike(@RequestParam(required = false, value = "configurationName") String ConfigurationName, @RequestParam(required = false, value = "configurationSection") String ConfigurationSection, @RequestParam(required = false, value = "configurationValue") String ConfigurationValue, Model uiModel) { uiModel.addAttribute("configurations", Configuration.findConfigurationsByConfigurationNameLikeOrConfigurationSectionLikeOrConfigurationValueLike(ConfigurationName, ConfigurationSection, ConfigurationValue).getResultList()); return "configurations/list"; }
I also modified the finder method in the entity...after pushing that in from the Finder.aj
But, while the find no longer throws errors, it also doesn't find anything with our without * or % characters.Code:public static TypedQuery<Configuration> findConfigurationsByConfigurationNameLikeOrConfigurationSectionLikeOrConfigurationValueLike(String ConfigurationName, String ConfigurationSection, String ConfigurationValue) { if (ConfigurationName == null || ConfigurationName.isEmpty()){ ConfigurationName = ""; } else { ConfigurationName = ConfigurationName.replace('*', '%'); if (ConfigurationName.charAt(0) != '%') { ConfigurationName = "%" + ConfigurationName; } if (ConfigurationName.charAt(ConfigurationName.length() - 1) != '%') { ConfigurationName = ConfigurationName + "%"; } } if (ConfigurationSection == null || ConfigurationSection.isEmpty()){ ConfigurationSection = ""; } else { ConfigurationSection = ConfigurationSection.replace('*', '%'); if (ConfigurationSection.charAt(0) != '%') { ConfigurationSection = "%" + ConfigurationSection; } if (ConfigurationSection.charAt(ConfigurationSection.length() - 1) != '%') { ConfigurationSection = ConfigurationSection + "%"; } } if (ConfigurationValue == null || ConfigurationValue.isEmpty()){ ConfigurationValue = ""; } else { ConfigurationValue = ConfigurationValue.replace('*', '%'); if (ConfigurationValue.charAt(0) != '%') { ConfigurationValue = "%" + ConfigurationValue; } if (ConfigurationValue.charAt(ConfigurationValue.length() - 1) != '%') { ConfigurationValue = ConfigurationValue + "%"; } } EntityManager em = Configuration.entityManager(); TypedQuery<Configuration> q = em.createQuery("SELECT o FROM Configuration AS o WHERE LOWER(o.ConfigurationName) LIKE LOWER(:ConfigurationName) OR LOWER(o.ConfigurationSection) LIKE LOWER(:ConfigurationSection) OR LOWER(o.ConfigurationValue) LIKE LOWER(:ConfigurationValue)", Configuration.class); q.setParameter("ConfigurationName", ConfigurationName); q.setParameter("ConfigurationSection", ConfigurationSection); q.setParameter("ConfigurationValue", ConfigurationValue); return q; }
Stumped.


Reply With Quote
but the finder works. I guess I can fix the forms easier than the plumbing.
