fixes grails-7729

I couldn't find a way to write a unit/integration test for this change, so here's how I tested it manually:

Create a new project and add these domain classes

````groovy
class Parent {
  static mapping = {
    tablePerHierarchy false  
  }
}

class Child extends Parent {
}
````
When you generate the schema there will be no foreign key relationship between Child and Parent. I then created the following class (which changes GrailsAnnotationConfiguration in an equivalent way to this PR):
````java
public class TablePerSubclassConfiguration extends GrailsAnnotationConfiguration {

    private static final long serialVersionUID = 1;
    private boolean subclassForeignKeysCreated = false;

    @Override
    protected void secondPassCompile() throws MappingException {
        super.secondPassCompile();

        if (subclassForeignKeysCreated) {
            return;
        }

        for (PersistentClass persistentClass : classes.values()) {
            if (persistentClass instanceof RootClass) {
                RootClass rootClass = (RootClass) persistentClass;

                if (rootClass.hasSubclasses()) {
                    Iterator subclasses = rootClass.getSubclassIterator();

                    while (subclasses.hasNext()) {

                        Object subclass = subclasses.next();

                        // This test ensures that foreign keys will only be created for subclasses that are
                        // mapped using "table per subclass"
                        if (subclass instanceof JoinedSubclass) {
                            JoinedSubclass joinedSubclass = (JoinedSubclass) subclass;
                            joinedSubclass.createForeignKey();
                        }
                    }
                }
            }
        }

        subclassForeignKeysCreated = true;
    }
}
````
and configured this class to be used in `DataSource.groovy`

````groovy
dataSource {
    configClass = 'TablePerSubclassConfiguration'
    // other datasource config goes here
}
````
Now when the schema is generated the foreign keys are created. I also added parent and child domain classes that use `tablePerHierarchy true` mapping to check that that they still work as before (and they do). 

I wasn't able to test that this doesn't break anything when the "table per concrete class" mapping is used, because I only have MySQL available, and this mapping strategy doesn't work with MySQL because it doesn't support sequences.

I don't know if the same problem exists when usiing Hibernate 4. If so, the same changes should obvioulsy be made to the corresponding class in `grails-datastore-gorm-hibernate4`.