sbglasius opened a new issue, #15364:
URL: https://github.com/apache/grails-core/issues/15364
### Expected Behavior
When using a common abstract base class for both entities and command
objects (injecting `Validateable`), the generated
GORM code (`id` and `version`) are injected into the domain class.
### Actual Behaviour
When using a common abstract base class for both entities and command
objects (injecting `Validateable`), the generated GORM code (`id` and
`version`) are injected into the abstract base class, and not into the entity
object as expected.
This results in a validation error on a command object extending an
abstract-base class that is also used to extend a domain class, on the fields
`id` and `version`, even though they should not be part of the command object.
### Example:
Base class:
```groovy
abstract class BaseFoo {
String foo
}
```
Domain class:
```groovy
class Foo extends BaseFoo {
static constraints = {
foo nullable: false
}
}
```
Command class:
Domain class:
```groovy
class FooCommand extends BaseFoo implements Validateable {
static constraints = {
foo nullable: false
}
}
```
The decompiled `BaseFoo.class` contains `id` and `version` fields.
```java
public abstract class BaseFoo implements GroovyObject {
private String foo;
Long id;
Long version;
// Getters and setters are generated into the base class as well.
}
```
### Steps To Reproduce
Check out the example project and run
```./gradlew clean test```
And the only test will fail.
### Environment Information
Ubuntu (irrelevant)
### Example Application
https://github.com/sbglasius/grails-gorm-abstract-id-bug
### Version
6.2.3 and 7.0.x
--
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]