Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2 final
-
Fix Version/s: 2.3-M2
-
Component/s: None
-
Labels:None
-
Patch Submitted:Yes
-
Patch attached:Yes
Description
If I try and mock a domain class that's being imported through hibernate, (ie not using groovy/GORM to define the class), grails will throw an error if I didn't define a version property in the hibernate mapping (either annotation or xml):
"Version property not found, but required in domain class "
This way it's impossible to mock domain classes that are shared with another Java projects.
A possible solution would be allowing mappings override with a Domain***Mappings.groovy (just like we define the GORM constraints).
I have exactly the same problem (using Grails 1.3.5) with JPA-annotated Java classes instead of using native Grails domain classes. The problem essentially lies in mocking the domain classes with the org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass which throws an exception in the constructor if version or identifier properties are missing. The reason for requiring these fields is not clear to me, so I modified the source and removed the said part in the constructor. All tests pass upon rebuilding Grails, as do tests in my application now with Grails modified in this way. I'll be attaching the relevant patch.