[hibernate-issues] [Hibernate-JIRA] Created: (HBX-1120) Incorrect ManyToMany Generation

Henry Chan (JIRA) noreply at atlassian.com
Wed Apr 15 01:39:17 EDT 2009


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


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: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list