简体   繁体   中英

One to One Mapping between two tables in Hibernate annotations

I have two tables

        CREATE TABLE `cb_jobs` (
    `JOB_IDENTIFIER` INT(11) NOT NULL,
    `CB_CREDENTIAL_TYPE_IDENTIFIER` INT(11) NOT NULL
    `IS_DELETED` TINYINT(1) NULL DEFAULT '0',
    PRIMARY KEY (`JOB_IDENTIFIER`),
    INDEX `FK_cb_jobs_cb_credential_type` (`CB_CREDENTIAL_TYPE_IDENTIFIER`)
    CONSTRAINT `FK_cb_jobs_cb_credential_type` FOREIGN KEY (`CB_CREDENTIAL_TYPE_IDENTIFIER`) REFERENCES `cb_credential_type` (`CB_CREDENTIAL_TYPE_IDENTIFIER`) ON UPDATE CASCADE ON DELETECASCADE)COLLATE='latin1_swedish_ci'
    ENGINE=InnoDB;    
    CREATE TABLE `cb_credential_type` (
    `CB_CREDENTIAL_TYPE_IDENTIFIER` INT(11) NOT NULL AUTO_INCREMENT,
    `CB_CREDENTIAL_CODE` VARCHAR(50) NULL DEFAULT NULL,
    `CB_CREDENTIAL_TYPE_NAME` VARCHAR(1000) NULL DEFAULT NULL,
    `CREATED_DATE` DATETIME NULL DEFAULT NULL,
    `CREATED_BY_USER` INT(11) NULL DEFAULT NULL,
    `UPDATED_DATE` DATETIME NULL DEFAULT NULL,
    `UPDATED_BY_USER` INT(11) NULL DEFAULT NULL,
    `IS_DELETED` TINYINT(1) NULL DEFAULT '0',
    PRIMARY KEY (`CB_CREDENTIAL_TYPE_IDENTIFIER`)
    )COLLATE='latin1_swedish_ci'
    ENGINE=InnoDB
    AUTO_INCREMENT=8;    

I would like to get the details of 2nd table based on the credential type id. How to write Hibernate mapping classes with one to one relationship using hibernate annotations.Anybody please help me.......

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM