Exception while fetching data [QueryDsl]

Kyle_Kim·2024년 3월 25일
0

결론 QueryDsl query에 reflection으로 사용되는 DTO는 @NoArgsConstructor가 필요하다.

2024-03-25 14:53:56.870  WARN 1294449 --- [nio-8081-exec-4] n.g.e.SimpleDataFetcherExceptionHandler  : Exception while fetching data (/aoiWfmiCountList) : com.kohyoung.ksmart.web.dto.AoiWfmiDto
 
  • Many Java frameworks and libraries use reflection to dynamically create instances of classes. Reflection is a powerful feature that allows a program to manipulate attributes and behaviors of objects at runtime. For instance, when QueryDSL fetches data from the database and maps it to a DTO (Data Transfer Object) like AoiWfmiDto, it doesn't use the constructor you've written. Instead, it uses reflection to instantiate the class without calling any constructor explicitly.

QueryDsl은 reflection사용시 어떤 필드가 들어올 지 모르기 때문에 일단 비어있는 객체를 생성한다 (= no args condtructor)

일단 비어져 있는 객체를 생성하면 DB에서 필요한 정보를 relfection에 맞게 뽑아 사용한다.

profile
Make Things Right

0개의 댓글