Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 2.0 final
-
Fix Version/s: 2.0.1
-
Component/s: Persistence
-
Labels:None
-
Testcase included:yes
Description
The attached integration tests demonstrates 2 scenarios where this behavior can be observed. In both tests the properties of 1 domains instance are copied to another.
In test1:
p1.properties["firstName", "lastName"] = newPerson.properties
In test2:
p1.properties = newPerson.properties.findAll{ it.key == "firstName" || it.key == "lastName"}
In both cases GORM will produce:
2012-01-26 09:38:48,178 [main] DEBUG hibernate.SQL - select this_.id as id0_0_, this_.version as version0_0_, this_.first_name as first3_0_0_, this_.last_name as last4_0_0_, this_.phone_number as phone5_0_0_ from person this_ 2012-01-26 09:38:48,180 [main] TRACE sql.BasicExtractor - found [1] as column [id0_0_] 2012-01-26 09:38:48,181 [main] TRACE sql.BasicExtractor - found [2] as column [id0_0_] 2012-01-26 09:38:48,181 [main] TRACE sql.BasicExtractor - found [3] as column [id0_0_] 2012-01-26 09:38:48,207 [main] DEBUG hibernate.SQL - select count(*) as y0_ from person this_ 2012-01-26 09:38:48,208 [main] TRACE sql.BasicExtractor - found [3] as column [y0_]
If you look at the SQL select, all fields of all records are fetched... I'm not sure why only the IDs are displayed in the logging. I would expect to see first_name, last_name and phone_number as well because they are in the SELECT...
In our application we have hundreds of records which get fetched together with their associations...
A simple workaround is to copy property by property. E.g.: p1.firstName = newPerson.firstName
-
Hide
- FetchAllRecordsBug.zip
- 26/Jan/12 7:07 AM
- 641 kB
- Svetozar Misljencevic
-
- FetchAllRecordsBug/.classpath 4 kB
- FetchAllRecordsBug/.project 0.9 kB
- FetchAllRecordsBug/.../com.springsource.sts.grails.core.prefs 0.2 kB
- FetchAllRecordsBug/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- FetchAllRecordsBug/.../org.eclipse.core.resources.prefs 1 kB
- FetchAllRecordsBug/.../org.eclipse.wst.common.project.facet.core.xml 0.1 kB
- FetchAllRecordsBug/application.properties 0.1 kB
- FetchAllRecordsBug/.../ApplicationResources.groovy 0.1 kB
- FetchAllRecordsBug/.../BootStrap.groovy 0.1 kB
- FetchAllRecordsBug/.../BuildConfig.groovy 2 kB
- FetchAllRecordsBug/.../Config.groovy 3 kB
- FetchAllRecordsBug/.../DataSource.groovy 1 kB
- FetchAllRecordsBug/.../resources.groovy 0.0 kB
- FetchAllRecordsBug/.../UrlMappings.groovy 0.2 kB
- FetchAllRecordsBug/.../Person.groovy 0.3 kB
- FetchAllRecordsBug/.../messages.properties 3 kB
- FetchAllRecordsBug/.../messages_cs_CZ.properties 3 kB
- FetchAllRecordsBug/.../messages_da.properties 3 kB
- FetchAllRecordsBug/.../messages_de.properties 4 kB
- FetchAllRecordsBug/.../messages_es.properties 3 kB
- FetchAllRecordsBug/.../messages_fr.properties 2 kB
- FetchAllRecordsBug/.../messages_it.properties 2 kB
- FetchAllRecordsBug/.../messages_ja.properties 4 kB
- FetchAllRecordsBug/.../messages_nl.properties 3 kB
- FetchAllRecordsBug/.../messages_pt_BR.properties 3 kB
- FetchAllRecordsBug/.../messages_pt_PT.properties 3 kB
- FetchAllRecordsBug/.../messages_ru.properties 4 kB
- FetchAllRecordsBug/.../messages_sv.properties 3 kB
- FetchAllRecordsBug/.../messages_th.properties 6 kB
- FetchAllRecordsBug/.../messages_zh_CN.properties 2 kB
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
The issue is the usage of obj.properties = obj2.properties. This for example doesn't produce the problem:
We are researching the issue and will have a fix shortly