Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.1, 2.0.2, 2.0.3
-
Fix Version/s: 2.0.4
-
Component/s: Persistence
-
Labels:
-
Environment:windows 7
-
Testcase included:yes
Description
when adding object and a sub-object to a collection (using domain mocks) a validation exception is being thrown
we believe it may be related to this code change for GrailsDomainClassValidator https://github.com/grails/grails-core/commit/59b3613348d314213ac23c78cd085ef02252767b#grails-core/src/main/groovy/org/codehaus/groovy/grails/validation/GrailsDomainClassValidator.java
code example below, attached full grails project
class Group {
String name
static hasMany = [members:Member]
static constraints = {
}
Collection <Member> members
}
class Member {
static constraints = {
}
String name
}
@ToString (includeNames=true,includeFields=true) class SubMemberA extends Member{ static constraints = { } String extraNameA }
import grails.test.mixin.* import org.junit.* /** * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions */ @TestFor(Group) @Mock([Group,SubMemberA,Member]) class GroupTests { Group group @Before void setUp() { group = new Group(name:"my group") def subMemeberA = new SubMemberA(name:"my name A",extraNameA:"extra name A") def member = new Member(name:"member") group.addToMembers subMemeberA group.addToMembers member group.save(failOnError:true) } @Test void testStructure() { assertNotNull Group.findById(group.id) } }
Exception throws is
| Running 1 unit test... 1 of 1 |
| Failure: testStructure(test.GroupTests) |
| java.lang.IllegalArgumentException: Argument [test.SubMemberA(extraNameA:extra name A)] is not an instance of [class test.Member] which this validator is configured for at org.grails.datastore.mapping.validation.ValidatingEventListener.doValidate(ValidatingEventListener.java:83) at org.grails.datastore.mapping.validation.ValidatingEventListener.beforeInsert(ValidatingEventListener.java:60) at org.grails.datastore.mapping.validation.ValidatingEventListener.onPersistenceEvent(ValidatingEventListener.java:47) at org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener.onApplicationEvent(AbstractPersistenceEventListener.java:46) at org.grails.datastore.mapping.engine.EntityPersister.cancelInsert(EntityPersister.java:228) at org.grails.datastore.mapping.engine.NativeEntryEntityPersister.executeInsert(NativeEntryEntityPersister.java:1370) at org.grails.datastore.mapping.engine.NativeEntryEntityPersister$1.run(NativeEntryEntityPersister.java:700) at org.grails.datastore.mapping.core.impl.PendingOperationExecution.executePendingOperation(PendingOperationExecution.java:33) at org.grails.datastore.mapping.core.AbstractSession.flushPendingOperations(AbstractSession.java:323) at org.grails.datastore.mapping.core.AbstractSession.flushPendingInserts(AbstractSession.java:315) at org.grails.datastore.mapping.core.AbstractSession.flush(AbstractSession.java:237) at org.grails.datastore.mapping.query.Query.flushBeforeQuery(Query.java:585) at org.grails.datastore.mapping.query.Query.list(Query.java:484) at org.grails.datastore.gorm.finders.AbstractFindByFinder.invokeQuery(AbstractFindByFinder.java:34) at org.grails.datastore.gorm.finders.AbstractFindByFinder$1.doInSession(AbstractFindByFinder.java:26) at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:301) at org.grails.datastore.gorm.finders.AbstractFinder.execute(AbstractFinder.java:40) at org.grails.datastore.gorm.finders.AbstractFindByFinder.doInvokeInternal(AbstractFindByFinder.java:24) at org.grails.datastore.gorm.finders.DynamicFinder.invoke(DynamicFinder.java:151) at org.grails.datastore.gorm.finders.DynamicFinder.invoke(DynamicFinder.java:352) at org.grails.datastore.gorm.GormStaticApi.methodMissing(GormStaticApi.groovy:108) at test.GroupTests.testStructure(GroupTests.groovy:32) |
-
Hide
- another-example.zip
- 10/Apr/12 12:07 AM
- 359 kB
- Alexander Kose
-
- another-example/.classpath 0.7 kB
- another-example/.project 0.5 kB
- another-example/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- another-example/application.properties 0.2 kB
- another-example/.../BootStrap.groovy 0.1 kB
- another-example/.../BuildConfig.groovy 1 kB
- another-example/grails-app/.../Config.groovy 4 kB
- another-example/.../DataSource.groovy 0.8 kB
- another-example/.../resources.groovy 0.0 kB
- another-example/.../UrlMappings.groovy 0.2 kB
- another-example/.../AbstractCustomPropertyValue.groovy 0.4 kB
- another-example/.../CustomProperty.groovy 0.2 kB
- another-example/.../StringPropertyValue.groovy 0.3 kB
- another-example/.../messages.properties 3 kB
- another-example/.../messages_da.properties 3 kB
- another-example/.../messages_de.properties 4 kB
- another-example/.../messages_es.properties 3 kB
- another-example/.../messages_fr.properties 2 kB
- another-example/.../messages_it.properties 2 kB
- another-example/.../messages_ja.properties 2 kB
- another-example/.../messages_nl.properties 3 kB
- another-example/.../messages_pt_BR.properties 3 kB
- another-example/.../messages_pt_PT.properties 3 kB
- another-example/.../messages_ru.properties 4 kB
- another-example/.../messages_th.properties 5 kB
- another-example/.../messages_zh_CN.properties 2 kB
- another-example/grails-app/.../error.gsp 2 kB
- another-example/grails-app/.../index.gsp 4 kB
- another-example/grails-app/.../main.gsp 0.8 kB
- another-example/stacktrace.log 33 kB
-
Hide
- new-example.zip
- 09/Apr/12 10:58 PM
- 868 kB
- Tomer Shtilman
-
- new-example/.classpath 4 kB
- new-example/.project 0.9 kB
- new-example/.../com.springsource.sts.grails.core.prefs 0.2 kB
- new-example/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- new-example/.../org.eclipse.core.resources.prefs 1 kB
- new-example/.../org.eclipse.wst.common.project.facet.core.xml 0.1 kB
- new-example/application.properties 0.1 kB
- new-example/.../ApplicationResources.groovy 0.1 kB
- new-example/grails-app/.../BootStrap.groovy 0.1 kB
- new-example/.../BuildConfig.groovy 2 kB
- new-example/grails-app/.../Config.groovy 4 kB
- new-example/grails-app/.../DataSource.groovy 1 kB
- new-example/grails-app/.../resources.groovy 0.0 kB
- new-example/.../UrlMappings.groovy 0.2 kB
- new-example/grails-app/.../test/Group.groovy 0.2 kB
- new-example/grails-app/.../Member.groovy 0.1 kB
- new-example/grails-app/.../SubMemberA.groovy 0.2 kB
- new-example/.../messages.properties 3 kB
- new-example/.../messages_cs_CZ.properties 3 kB
- new-example/.../messages_da.properties 3 kB
- new-example/.../messages_de.properties 4 kB
- new-example/.../messages_es.properties 3 kB
- new-example/.../messages_fr.properties 2 kB
- new-example/.../messages_it.properties 2 kB
- new-example/.../messages_ja.properties 4 kB
- new-example/.../messages_nl.properties 3 kB
- new-example/.../messages_pt_BR.properties 3 kB
- new-example/.../messages_pt_PT.properties 3 kB
- new-example/.../messages_ru.properties 4 kB
- new-example/.../messages_sv.properties 3 kB
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
Hide
Yoann Trouillet
added a comment -
This issue is well documented - from two different developers - with tests attached. Could we please have this issue scheduled in 2.0.4?
Show
Yoann Trouillet
added a comment - This issue is well documented - from two different developers - with tests attached. Could we please have this issue scheduled in 2.0.4?
Add another simple example.