0

How do you prevent foreign keys from being generated in Grails 3?

In Grails 2 you would override the secondPassCompile() method of GrailsAnnotationConfiguration class and do something like this:

for(PersistentClass pc : classes.values()) {
     for(Iterator iterator = pc.getTable().getForeignKeyIterator(); iterator.hasNext(); ) {
        ForeignKey fk = (ForeignKey) iterator.next();               
        iterator.remove();      
     }
}
  1. How would I achieve the same using Grails 3.2.3 with Hibernate 5?
  2. What about using Grails 3.2.3 with Hibernate 4?

The GORM docs mentioned that GrailsAnnotationConfiguration has been replaced with HibernateContextMappingConfiguration but I am unable to make it work.

Viriato
  • 2,981
  • 7
  • 40
  • 54
  • I added an answer for Hibernate 5 on this similar question: http://stackoverflow.com/questions/4768231 – timbonicus Apr 21 '17 at 17:23
  • Possible duplicate of [GORM prevent creation of a foreign key constraint for a Domain](http://stackoverflow.com/questions/4768231/gorm-prevent-creation-of-a-foreign-key-constraint-for-a-domain) – timbonicus Apr 21 '17 at 17:23
  • @timbonicus Thanks for your answer on your other question, I will have to give it a try. Can you put the answer over into this question as well since I specifically asked for Grails 3 and in the other question the user marked as correct the answer for a Grails 2 implementation? – Viriato Apr 21 '17 at 22:03

0 Answers0