Hi guys,
I've been using Roo since 1.0.0 and decided for my new projects I want to use the database as the domain model and reverse engineer it for the project. So I've got all my schema written, call roo to generate the domain model, and.... hmm... no relationships. Hadn't thought about that, really, they're just always there. ;-)
Here's a data model. Even though MySQL doesn't really support foreign keys (and I guess that's why it's not mapped correctly), I've included them in the schema:
When this is reverse engineered, I get mappings likeCode:create table folder ( id bigint not null auto_increment, title varchar(100) not null, primary key (id) ) ENGINE=InnoDB; create table language ( id bigint not null auto_increment, name varchar(30), code varchar(3), primary key (id) ) ENGINE=InnoDB; create table document ( id bigint not null auto_increment, folderId int not null, title varchar(100) not null, primary key (id), FOREIGN KEY (folderId) REFERENCES folder(id) ) ENGINE=InnoDB; create table page ( id bigint not null auto_increment, version int not null default 1, documentId int not null, languageId int not null default 1, fileName varchar(100), primary key (id), FOREIGN KEY (documentId) REFERENCES document(id), FOREIGN KEY (languageId) REFERENCES language(id) ) ENGINE=InnoDB;
where I was hoping/expecting something like this:Code:@Column(name = "languageId") @NotNull private Integer Page.languageid;
Do I need to do the relationship mapping myself, or is there something I'm missing? It's been very good so far letting Roo take care of the relationships, so I'm hoping to keep using that with the reverse engineering as well.Code:@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name = "languageId", nullable = false, referencedColumnName="id") @ForeignKey(name="FK_LanguageID") private Language Page.language;
Cheers
Nik


Reply With Quote
