Grails mappedBy

时间:2012-06-27 15:55:57

标签: grails

我在Grails中做了一个简单的程序,并且遇到了多对多关系的问题。我有一个机场班:

class Airport 
{
   static hasMany = [outgoingFlights:Flight, incomingFlights:Flight]
   static mappedBy = [outgoingFlights:'departureAirport', 
                      incomingFlights:'arrivalAirport']
}

和飞行课程:

class Flight
{
   Airport departureAirport
   Airport arrivalAirport
}

由于某种原因,它为mappedBy提供了一个非常长而奇怪的错误消息。 mappedBy代码有问题还是我还需要做其他事情?感谢。

1 个答案:

答案 0 :(得分:0)

请试试这个:

class Flight
{
   static belongsTo = [departureAirport: Airport, arrivalAirport: Airport ]
   Airport departureAirport
   Airport arrivalAirport
}

重新创建数据库。