(Quick Reference)



The mappedBy static property adds the ability to change how a bidirectional associations is linked


class Airport {
    static mappedBy = [outgoingFlights:'departureAirport',
    static hasMany = [outgoingFlights:Route,
                      incomingFlights: Rout]

class Route { Airport departureAirport Airport destinationAirport }

In this example the Airport class defines two bidirectional one-to-many associations. Without defining mappedBy this is impossible as GORM cannot differentiate which of the two properties on the other end of the association (either departureAirport or destinationAirport in the Route class) each one-to-many should be associated one.

The solution is to define mappedBy which tells the Airport class how each association relates to the other side.