5
엔티티 (작성자)와 모든 작성자를 렌더링하는 제어기 조치가 있습니다. 페이지를 렌더링 할 때페이지를 새로 고칠 때 grails에서 이상한 GORM 동작이 발생했습니다. (F5)
def index = {
def list = Author.list()
render(view: 'index', model: ['allauthors' : list])
}
, 단일 쿼리가 예상대로 실행됩니다
Hibernate:
select
this_.id as id0_0_,
this_.version as version0_0_,
this_.name as name0_0_
from
author this_
을하지만, 내가 새로 고침 (F5)을 누르면 다음 선택 문이 각 저자 (여기 내가 3이 실행된다 작성자) :
Hibernate:
select
author0_.id as id0_0_,
author0_.version as version0_0_,
author0_.name as name0_0_
from
author author0_
where
author0_.id=?
Hibernate:
select
author0_.id as id0_0_,
author0_.version as version0_0_,
author0_.name as name0_0_
from
author author0_
where
author0_.id=?
Hibernate:
select
author0_.id as id0_0_,
author0_.version as version0_0_,
author0_.name as name0_0_
from
author author0_
where
author0_.id=?
왜 이런 일이 발생합니까?
를 두 번째 수준의 캐싱은 기본적으로 해제되어 있기 때문에이 될 수 있습니다. 새로 고침 기능을 많이 보게되면 list() 호출에서 cache 매개 변수를 전달하여 목록 쿼리를 캐시 할 수 있습니다. –
이상한 점은 Author.book()이 처음으로 일반적인 단일 select 문을 실행하지만 새로 고칠 때 각 작성자에 대해 여러 select 문을 실행한다는 것입니다. 어떤 아이디어? – geo
Grails 레벨이 아닌 최대 절전 모드 레벨에서 더 잘 설명 될 수 있다고 생각하기 때문에 나는 hibernate 태그를 추가했다. –