]
Henry Chan commented on HBX-1120:
---------------------------------
might be related to
Incorrect ManyToMany Generation
-------------------------------
Key: HBX-1120
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-1120
Project: Hibernate Tools
Issue Type: Bug
Environment: MySQL v5.1
Hibernate Tools 3.2.4
Reporter: Henry Chan
Attachments: hibernateSchemaExport.sql
When I run the reverse Engineering Tool to generate my classes, one of these classes does
not have the correct manytomany annotation defined correctly:
In the example below, the I have User, User_Role and Role
The User classgets generated correctly:
User.java ...
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "user_role", catalog = "exms", joinColumns = {
@JoinColumn(name = "userID", nullable = false, updatable = false) },
inverseJoinColumns = { @JoinColumn(name = "roleID", nullable = false, updatable
= false) })
public Set<Role> getRoles() {
return this.roles;
}
but Role.java class isn't correct:
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
public Set<User> getUsers() {
return this.users;
}
Where is the @JoinTable in Role.java?
DROP TABLE IF EXISTS `exms`.`Role` ;
CREATE TABLE IF NOT EXISTS `exms`.`Role` (
`roleID` INT NOT NULL AUTO_INCREMENT ,
`roleName` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`roleID`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `exms`.`Login`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `exms`.`Login` ;
CREATE TABLE IF NOT EXISTS `exms`.`Login` (
`loginID` INT NOT NULL AUTO_INCREMENT ,
`userID` INT NULL ,
`timeStamp` DATETIME NULL ,
`failedLogins` INT NULL ,
PRIMARY KEY (`loginID`) ,
INDEX `fk_Login_User` (`userID` ASC) ,
CONSTRAINT `fk_Login_User`
FOREIGN KEY (`userID` )
REFERENCES `exms`.`User` (`userID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `exms`.`User_Role`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `exms`.`User_Role` ;
CREATE TABLE IF NOT EXISTS `exms`.`User_Role` (
`userID` INT NOT NULL ,
`roleID` INT NOT NULL ,
INDEX `fk_User_Role_User` (`userID` ASC) ,
INDEX `fk_User_Role_Role` (`roleID` ASC) ,
PRIMARY KEY (`userID`, `roleID`) ,
CONSTRAINT `fk_User_Role_User`
FOREIGN KEY (`userID` )
REFERENCES `exms`.`User` (`userID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_User_Role_Role`
FOREIGN KEY (`roleID` )
REFERENCES `exms`.`Role` (`roleID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: