I'm using Eclipse with Hibernate Tools to do reverse engineering. I get the classes but all the relationshipt between them are missed. So, it doesn't matter if there're many-to-many or whatever because they are not on my classes.
Right now, I am only trying with two tables:
CREATE TABLE `ROOMS` ( `idROOMS` int(11) NOT NULL, `ROOM_NAME` varchar(45) DEFAULT NULL, `OWNER` int(11) DEFAULT NULL, `IS_PRIVATED` tinyint(1) DEFAULT NULL, `CREATED_DATE` datetime DEFAULT NULL, PRIMARY KEY (`idROOMS`), UNIQUE KEY `UNI_NAME_ROOM` (`ROOM_NAME`), KEY `FK_OWNER_idx` (`OWNER`), CONSTRAINT `FK_OWNER` FOREIGN KEY (`OWNER`) REFERENCES `USERS` (`idUSERS`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `USERS` ( `idUSERS` int(11) NOT NULL, `USER_NAME` varchar(50) DEFAULT NULL, `KEY_ID` varchar(1000) DEFAULT NULL, PRIMARY KEY (`idUSERS`), UNIQUE KEY `UNI` (`USER_NAME`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; It's not correctly defined the relationship between the tables?
I'm getting something like:
/** * Users generated by hbm2java */ @Entity @Table(name = "USERS", catalog = "test_hibernate", uniqueConstraints = @UniqueConstraint(columnNames = "USER_NAME")) public class Users implements java.io.Serializable {
private int idUsers; private String userName; private String keyId; ...
@Entity @Table(name = "ROOMS", catalog = "test_hibernate", uniqueConstraints = @UniqueConstraint(columnNames = "ROOM_NAME")) public class Rooms implements java.io.Serializable {
private int idRooms; private String roomName; private Integer owner; --> I'd like getting a Set<Users> or something like that, I think that it's as Hibernate works. private Boolean isPrivated; private Date createdDate;
|