2

Does GORM 6.1.8.RELEASE for Hibernate require any changes to domain classes?

Is joinTable in the domain mapping a recent addition to GORM?

I copied my domain classes from a working Grails 2.5.1 project to a Grails 3.2 project. When I launch the skeleton app with "dbCreate: 'validate'" I get the following error:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.MappingException: Foreign key (FK56o1sv2813gshwyyok919a6gp:library_document_attachments [])) must have same number of columns as the referenced primary key (library_document [id])

I don't have a composite key or any custom mapping in the association.

class LibraryDocument extends Trackable {

// Attributes
...

// Relationships
Attachment latestVersion
static belongsTo = [...]

SortedSet attachments
static hasMany = [attachments: Attachment]
...
}

Project Version information:

grailsVersion=3.3.2
gormVersion=6.1.8.RELEASE
gradleWrapperVersion=3.5
user1452701
  • 144
  • 1
  • 10
  • @JeffScottBrown Is there any documentation on upgrading from Grails 2.5 to Grails 3.2? I would be epically interested in what to look for when migrating domain classes. – user1452701 Jan 18 '18 at 20:35
  • You can refer this https://stackoverflow.com/questions/53514129/unable-to-start-grails-3-3-8-application-with-postgres-db/53530067#53530067 and see if it helps. – Hasan K Nov 30 '18 at 06:41

1 Answers1

1

Does GORM 6.1.8.RELEASE for Hibernate require any changes to domain classes?

The answer to that will depend on a number of factors in your application. There are lots of domain classes for which no changes will be required.

Is joinTable in the domain mapping a recent addition to GORM?

No. We added that about 10 years ago and it was included in 1.0. https://github.com/grails/grails-core/commit/de590be6452715a119931d26bcc50c6a72e96170

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
  • Is there any documentation on what changes are required for domain classes when upgrading from Grails 2.x to 3.x? – user1452701 Jan 19 '18 at 04:35
  • "Is there any documentation on what changes are required for domain classes when upgrading from Grails 2.x to 3.x?" - No. There is no way to know what code you might have in a domain class. We document specific things that have changed in the framework, but that isn't a list of changes required while upgrading. If creating such a list was do-able, we would just write a script that does the upgrade. The approach to use is understand how the version you are using works, and make your code compliant with that. For domains, that is usually trivial. – Jeff Scott Brown Jan 19 '18 at 13:47
  • If you can provide a sample app which demonstrates the issue with 3.3.2, it would probably take only a few minutes to identify the issue. – Jeff Scott Brown Jan 19 '18 at 13:47