我正在尝试运行我的应用。我有一个grails项目2.4.3版本,我正在使用Hibernate4。 在我的BuildConfig.groovy文件中,我有:
dependencies {
test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
compile "org.jadira.usertype:usertype.jodatime:2.0"
}
plugins {
compile ":joda-time:1.5"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.5.5" // or ":hibernate:3.6.10.17"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
}
在我的Config.groovy文件中,我有:
grails.gorm.default.mapping = {
"user-type" type: org.jadira.usertype.dateandtime.joda.PersistentDateTime, class: org.joda.time.DateTime
"user-type" type: org.jadira.usertype.dateandtime.joda.PersistentDurationAsString, class: org.joda.time.Duration
"user-type" type: org.jadira.usertype.dateandtime.joda.PersistentInstantAsMillisLong, class: org.joda.time.Instant
"user-type" type: org.jadira.usertype.dateandtime.joda.PersistentInterval, class: org.joda.time.Interval
"user-type" type: org.jadira.usertype.dateandtime.joda.PersistentLocalDate, class: org.joda.time.LocalDate
"user-type" type: org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime, class: org.joda.time.LocalDateTime
"user-type" type: org.jadira.usertype.dateandtime.joda.PersistentLocalTime, class: org.joda.time.LocalTime
"user-type" type: org.jadira.usertype.dateandtime.joda.PersistentPeriodAsString, class: org.joda.time.Period
}
我从另一个grails项目中复制了一组dominion类但1.3.5版本,我运行应用程序并创建了表但有错误:
Hibernate: alter table ventas_pago add constraint FK_6j2qual02owvkq48xga6fki9s foreign key (medio_pago_id) references medio_pago (id_medio_pago)
Hibernate: alter table ventas_pago add constraint FK_rbhjla1vjr4asrpryc4yy4wjv foreign key (id_venta) references venta (id_venta)
Hibernate: alter table ventas_pago add constraint FK_cs3k59ycva16s5r6iu8586em2 foreign key (id_ventas_pago) references entidad (id)
Error |
2015-03-05 10:01:32,859 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table ventas_pago add constraint FK_cs3k59ycva16s5r6iu8586em2 foreign key (id_ventas_pago) references entidad (id)
Error |
2015-03-05 10:01:32,859 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Cannot add foreign key constraint
任何人都知道为什么会这样?
感谢您的时间和答案。