CHAAAAA opened a new issue, #14563:
URL: https://github.com/apache/grails-core/issues/14563

   Hi, I use Grails3.3.5, `lazy: false` seems not work. When execute 
`Airport.findByName("Gatwick")`, only one SQL statement generated. But if I 
change it to `fetch: 'join'`, it works well.
   
   ```
   | OS: macOS 10.13.5
   | Grails Version: 3.3.5
   | Groovy Version: 2.4.15
   | JVM Version: 1.8.0_111
   ```
   
   ```groovy
   // Domain Classes
   class Airport {
       String name
       static hasMany = [flights: Flight]
   
       static mapping = {
           flights lazy: false
       }
   }
   class Flight {
       String number
       Location destination
       static belongsTo = [airport: Airport]
   }
   class Location {
       String city
       String country
   }
   ```
   
   ```groovy
   // Controller
   def airport = Airport.findByName("Gatwick")
   println 'start access data...'
   println ''
   
   for (flight in airport.flights) {
       println ''
       println 'load Location data...'
       println flight.destination.city
   }
   ```
   
   ```
   // log
   Hibernate: select this_.id as id1_0_0_, this_.version as version2_0_0_, 
this_.name as name3_0_0_ from airport this_ where this_.name=? limit ?
   
   start access data...
   
   Hibernate: select flights0_.airport_id as airport_5_1_0_, flights0_.id as 
id1_1_0_, flights0_.id as id1_1_1_, flights0_.version as version2_1_1_, 
flights0_.number as number3_1_1_, flights0_.destination_id as destinat4_1_1_, 
flights0_.airport_id as airport_5_1_1_ from flight flights0_ where 
flights0_.airport_id=?
   
   load Location data...
   Hibernate: select location0_.id as id1_4_0_, location0_.version as 
version2_4_0_, location0_.city as city3_4_0_, location0_.country as 
country4_4_0_ from location location0_ where location0_.id=?
   
   load Location data...
   Hibernate: select location0_.id as id1_4_0_, location0_.version as 
version2_4_0_, location0_.city as city3_4_0_, location0_.country as 
country4_4_0_ from location location0_ where location0_.id=?
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to