when I define a repository as:
and invoke in controller:Code:public interface OrganizationRepository extends CrudRepository<Organization, Long> { @Query("select o.name from Organization o where o.name like :pattern ") List<String> findCompanyName(@Param("pattern") String name); }
at runtime, I get the a debug info like:Code:@Controller @RequestMapping("/organization") public class OrganizationController { @Autowired private OrganizationRepository organizationRepository; @RequestMapping(value="/names", method=RequestMethod.GET) public @ResponseBody List<String> getCompanyNameList(@RequestParam String term) throws Exception{ List<String> companyNames=organizationRepository.findCompanyName(term); return companyNames; } }
and can't get the expected result?Code:2012-02-18 16:35:40,763 DEBUG: select organizati0_.name as col_0_0_ from Organization organizati0_ where organizati0_.name like ? >>> org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:104) Hibernate: select organizati0_.name as col_0_0_ from Organization organizati0_ where organizati0_.name like ?
I suppose the sql should be something like:
where is the problem?Code:select organizati0_.name as col_0_0_ from Organization organizati0_ where organizati0_.name like 'abc'


I suppose the sql should be something like:
Reply With Quote
