Open aulea opened 5 years ago
Can this be considered for inclusion in a release?
We are running a custom build with the fix attached with no problems for some time. It would be nice if we could stop having to build this fix ourselves.
I am seeing similar behavior with Grails 4.0.3/GORM 7.0.4.RELEASE where I am getting the not an entity exception being thrown on an embedded object.
I've issued PR #378 to address this based on the 7.0.x branch.
@longwa Can you help to build a new tag released include this patch. Without this patch, the error for save failed will be wrong when it has embedded column that is not declared as entity.
Given the following Domain class
and Embedded class
Steps to Reproduce
When trying to save new instance of domain A with validation error, it fails instead with IllegalArgumentException from Hibernate telling that embedded class E is not an entity. Of course that's true, but i would expect to get original ValidationException.
Originally posted under grails-data-mapping (1199)
The Stacktrace:
The reason is, that gorm tries to set objects with failure to read-only state in hibernate session, but doesn't distinct correctly Embedded objects: AbstractHibernateGormInstanceApi#handleValidationError It loops over all domain's associations and check their instance type ToOne, it should exclude instance type Embedded.
Expected Behaviour
Should fail with ValidationException for validated field
Actual Behaviour
Fails with IllegalArgumentException from Hibernate: Not an Entity [class E]
Environment Information
Workaround is to use manual validation before save and throw by youself new ValidationException created from validated domain errors.