dbre mysql 'Foreign key table for foreign key' 'must not be null'
Given the following mysql database definition for user 'sa' and no password:
Code:
-- DROP SCHEMA IF EXISTS rootest;
-- CREATE SCHEMA rootest DEFAULT CHARACTER SET utf8;
-- USE rootest;
DROP TABLE IF EXISTS TeamPlayer;
DROP TABLE IF EXISTS Player;
DROP TABLE IF EXISTS Team;
DROP TABLE IF EXISTS PlayerStatusType;
DROP TABLE IF EXISTS User;
-- =================================
CREATE TABLE User
(
id bigint auto_increment PRIMARY KEY
)
ENGINE = InnoDB;
-- ================================
CREATE TABLE PlayerStatusType
(
type varchar(63) PRIMARY KEY
)
ENGINE = InnoDB;
-- ===============================
CREATE TABLE Team
(
id bigint auto_increment,
city varchar(127) not null,
name varchar(127) not null,
version int,
primary key(id),
unique(city, name)
)
ENGINE = InnoDB;
-- ================================
CREATE TABLE Player
(
id bigint auto_increment,
firstName varchar(63),
lastName varchar(63) not null,
birthdate date not null,
statusType varchar(63) not null,
version int,
primary key(id),
foreign key(statusType) references PlayerStatusType(type)
)
ENGINE = InnoDB;
-- ===================================
CREATE TABLE TeamPlayer
(
teamId bigint,
playerId bigint,
fromDate date,
toDate date,
version int,
primary key(teamId, playerId, fromDate),
foreign key(teamId) references Team(id),
foreign key(playerId) references Player(id)
)
ENGINE = InnoDB;
-- ===================================
and the following roo project scripts:
Code:
// Create project
project --topLevelPackage com.roodbtest
// Setup database
persistence setup --provider HIBERNATE --database MYSQL
database properties set --key database.url --value jdbc:mysql://localhost:3306/rootest
database properties set --key database.username --value sa
database properties list
edit persistence.xml changing hibernate.hbm2ddl.auto value to 'validate'
Code:
// database reverse engineer
///////////
database reverse engineer --schema rootest --package ~.domain --testAutomatically
the following output results:
Code:
Created SRC_MAIN_RESOURCES/dbre.xml
Updated ROOT/pom.xml
Updated SRC_MAIN_RESOURCES/META-INF/persistence.xml
Created SRC_MAIN_JAVA/com/roodbtest/domain
Created SRC_MAIN_JAVA/com/roodbtest/domain/Player.java
Created SRC_MAIN_JAVA/com/roodbtest/domain/PlayerStatusType.java
Created SRC_MAIN_JAVA/com/roodbtest/domain/Team.java
Created SRC_MAIN_JAVA/com/roodbtest/domain/TeamPlayerPK.java
Created SRC_MAIN_JAVA/com/roodbtest/domain/TeamPlayer.java
Created SRC_MAIN_JAVA/com/roodbtest/domain/User.java
Undo create SRC_MAIN_JAVA/com/roodbtest/domain/User.java
Undo create SRC_MAIN_JAVA/com/roodbtest/domain/TeamPlayer.java
Undo create SRC_MAIN_JAVA/com/roodbtest/domain/TeamPlayerPK.java
Undo create SRC_MAIN_JAVA/com/roodbtest/domain/Team.java
Undo create SRC_MAIN_JAVA/com/roodbtest/domain/PlayerStatusType.java
Undo create SRC_MAIN_JAVA/com/roodbtest/domain/Player.java
Undo create SRC_MAIN_JAVA/com/roodbtest/domain
Undo manage SRC_MAIN_RESOURCES/META-INF/persistence.xml
Undo manage ROOT/pom.xml
Undo create SRC_MAIN_RESOURCES/dbre.xml
Foreign key table for foreign key 'player_ibfk_1' in table 'Player' must not be null in determining a one-to-one relationship
Script required 2 second(s) to execute
Script execution aborted
Created SRC_MAIN_JAVA/com/roodbtest/domain
Created SRC_MAIN_JAVA/com/roodbtest/domain/Player_Roo_Entity.aj
Deleted SRC_MAIN_JAVA/com/roodbtest/domain/Player_Roo_Entity.aj
This is a very simple database structure.
Why does roo have a problem?
Is this a roo defect?
Am I missing a step or doing something incorrect?
I am using roo 1.1.4.