【发布时间】:2021-03-06 09:17:36
【问题描述】:
我有一个奇怪的事情。 当我从我的服务调用一个函数时,该服务丢失了所有参数。 我不知道何时以及为什么。
调试说当他们进入类时有参数,然后什么都没有。 我在另一个服务中做了一个类似的功能,它可以工作。真的很奇怪。
看(调试打印):
cftimesheet.web.rest.AppUserResource 输入:getAllAppUsersByCompany() with argument[s] = [1, AppUserCriteria{}, Page request [number: 0, size 20, sort: undefined: DESC,id: ASC]]
c.f.timesheet.web.rest.AppUserResourceREST 请求按公司 ID 获取 AppUsers:1
c.f.timesheet.service.AppUserService 输入:findByCompany() with argument[s] = [1, Page request [number: 0, size 20, sort: undefined: DESC,id: ASC]]
c.f.timesheet.service.AppUserService : 请求通过公司 id 获取所有 AppUsers !!!!!!!!!!!!!!!!!!!!!问题 id 丢失
findByCompany() 中的异常,原因 = 'java.lang.IllegalArgumentException:org.hibernate.QueryException:无法解析属性:未定义:com.freemind.timesheet.domain.AppUser [从 com.freemind.timesheet 中选择 appUser .domain.AppUser appUser where appUser.id=?1 order by appUser.undefined desc, appUser.id asc]'
代码如下:
AppUserRessource:
@GetMapping("/app-users/company/{id}")//tayo
public ResponseEntity<List<AppUserDTO>> getAllAppUsersByCompany(@PathVariable Long id,Pageable pageable) {
log.debug("REST request to get AppUsers by company id: {}", id);
Page<AppUserDTO> page = appUserService.findByCompany(id,pageable);
return ResponseEntity.ok().body(page.getContent());
}
应用用户服务
public Page<AppUserDTO> findByCompany(Long id,Pageable pageable){//?
log.debug("Request to get all AppUsers by company id", id);
return appUserRepository.findByCompany(id,pageable).map(appUserMapper::toDto);
}
查询:
@Query("select appUser from AppUser appUser where appUser.id=?1")
Page<AppUser> findByCompany( Long id, Pageable pageable);
你有什么想法吗?
谢谢。
【问题讨论】:
标签: java spring-boot jpa jhipster