エンティティ(作成者)と、すべての作成者をレンダリングするコントローラーアクションがあります。
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)を押すと、作成者ごとにselectステートメントが実行されます(ここでは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=?
なぜこれが起こったのですか?