sciros opened a new issue, #14637:
URL: https://github.com/apache/grails-core/issues/14637
I am experiencing a recurring issue regarding one-to-many mappings and the
generated schema.
Using Grails 3.1.8 and grails-datastore-\* 5.0.8.
The code is basically as follows:
```
class Feature implements GormEntity<Feature> {
String name
String uri
Set scenarios = []
Run run
static belongsTo = [run: Run]
static hasMany = [scenarios: Scenario]
}
class Scenario implements GormEntity<Scenario> {
Date created
String keyword
String name
String uri
Set<Step> steps = []
Set<Hook> hooks = []
Background background
Feature feature
static belongsTo = [feature: Feature]
static hasMany = [steps: Step, hooks: Hook] //includes background steps
...
}
class Hook implements GormEntity<Hook> {
String error
HookType hookType
Scenario scenario
static belongsTo = [scenario: Scenario]
static constraints = {
error nullable: true
}
}
```
(There is also a Run and a Step class but they are straightforward and
exactly what you'd expect from looking at the ones above.) Anyway, I feel like
I've already added a kind of redundancy in the code by explicitly specifying
fields for some of the mappings as well as types. Nevertheless, after executing
a Grails integration test run (or dev startup) I occasionally get the following
error:
```
Caused by: org.hibernate.MappingException: Missing type or column for
column[hooks_hook] on domain[com.sciros.cucumber.reporting.types.Scenario]
referencing[com.sciros.cucumber.reporting.types.Hook]
at
org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.bindCollectionWithJoinTable(AbstractGrailsDomainBinder.java:719)
at
org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.bindCollectionSecondPass(AbstractGrailsDomainBinder.java:521)
at
org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder$GrailsCollectionSecondPass.doSecondPass(AbstractGrailsDomainBinder.java:172)
at
org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426)
at
org.grails.orm.hibernate.cfg.HibernateMappingContextConfiguration.secondPassCompile(HibernateMappingContextConfiguration.java:287)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
at
org.grails.orm.hibernate.cfg.HibernateMappingContextConfiguration.buildSessionFactory(HibernateMappingContextConfiguration.java:196)
at
org.grails.orm.hibernate.HibernateMappingContextSessionFactoryBean.doBuildSessionFactory(HibernateMappingContextSessionFactoryBean.java:476)
```
If I perform a `grails clean` then things are OK for a couple of test runs.
Eventually I run into this error again. Having spent time away from coding in
Grails and GORM for a while, I am not sure this is an actual "issue" to submit
as opposed to a coding error on my part. That said, I see nothing that
indicates an error and the code appears to work "some" of the time (integration
tests running queries that require proper mapping pass).
--
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]