更新:我已经更改了初始帖子的内容。我试图简化原来的问题,并且还提供了一些其他信息
我一直在尝试在旧版MS SQL Server数据库上使用db-reverse-engineer。在尝试使用实际系统之前,我通过了db-reverse-engineer教程,熟悉了基于生产的数据库可能需要的工具和模式。
在我们的项目上运行db-reverse-engineer之后,我将实体代码复制到使用 GORM独立的Groovy脚本(引用此Gist获取完整代码:https://gist.github.com/restagner/f2f740d5599efa202b08)
当我尝试运行脚本时,会产生以下错误并创建一个标有master_licenses
的全新表格。我不知道如何解决这个问题。
我的印象是我可以使用addTo *样式方法添加某些域对象。我确信我忽略了一些明显的东西,但我无法弄明白。我已经查看了Grails文档,但无法了解我出错的地方。
Mar 13, 2015 8:19:16 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: HHH000388: Unsuccessful: alter table master_licenses add constraint FK_fh56msfgiqs28dhbqp4uyt34f foreign key (master_id) references master
Mar 13, 2015 8:19:16 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: Column 'master.master_id' is not the same data type as referencing column 'master_licenses.master_id' in foreign key 'FK_fh56msfgiqs28dhbqp4uyt34f'.
Caught: groovy.lang.MissingMethodException: No signature of method: Master.addToLicenses() is applicable for argument types: (License) values: [License : (unsaved)]
Possible solutions: getLicenses()
并且,这里是每个表格的DDL列表
CREATE TABLE license (
license_id int IDENTITY(1,1) NOT NULL,
artist_id int,
territory_id int,
project varchar(255) NOT NULL,
project_type_id int,
label_id char(3),
fee money DEFAULT ((0.00)),
fee_currency_id int,
licensee_id int,
contract_date datetime,
license_status_id char(1),
license_term_id char(1),
term_end_date datetime,
notes nvarchar(max),
setup_by_id varchar(10),
setup_date datetime,
updated_by_id varchar(10),
updated_date datetime,
term_notes varchar(4000),
fee_id int,
royalty_term varchar(50),
license_status_notes varchar(4000),
media_type_id int,
media_type_notes varchar(255),
option_ind char(1),
option_notes varchar(4000),
territory_notes varchar(255),
license_product_id int,
release_date datetime,
return_date datetime,
licensee_contact nvarchar(255),
amount_received money,
balance_of_advance money,
royalties_earned money,
units int,
PRIMARY KEY (license_id)
);
主表
CREATE TABLE master (
master_id int IDENTITY(1,1) NOT NULL,
title nvarchar(255) NOT NULL,
original_label_id char(3) NOT NULL,
duration nvarchar(8),
recording_type_id int NOT NULL,
asset_type nvarchar(5),
isrc nvarchar(15),
sap_issue_num char(12),
language_id smallint,
p_notice_year nvarchar(4),
p_notice_text nvarchar(255),
recording_date_text nvarchar(100),
territory_id int,
location_recording nvarchar(255),
location_mixing nvarchar(255),
location_mastering nvarchar(255),
aftra_ind char(1),
afm_ind char(1),
courtesy_of_text nvarchar(255),
comments nvarchar(max),
parental_advisory_ind char(1),
status char(1),
royalty_master_id numeric(18),
country_of_origin_id int,
contain_samples char(1),
misc_label_copy nvarchar(max),
asset_type_id int,
setup_by_id nvarchar(10),
setup_date datetime NOT NULL,
updated_by_id nvarchar(10),
updated_date datetime,
english_title nvarchar(255),
version_title nvarchar(80),
parental_ind_id int,
isrc_cloned nvarchar(15),
send_to_umg_ind char(1),
send_to_umg_date datetime,
PRIMARY KEY (master_id)
);
License_Master表 - 连接表
CREATE TABLE license_master (
license_id int NOT NULL,
master_id int,
setup_by_id char(10),
setup_date datetime,
updated_by_id char(10),
updated_date datetime,
amount money
);