国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
Hibernate Unidirectional associations

7.2. Unidirectional associations

7.2.1. many to one

A unidirectional many-to-one association is the most common kind of unidirectional association.

<class name="Person"><id name="id" column="personId"><generator class="native"/></id><many-to-one name="address"column="person_address_id"not-null="true"/></class><class name="Address"><id name="id" column="addressId"><generator class="native"/></id></class>
create table Person ( 
    personId bigint not null primary key, 
    person_address_id bigint not null,
    CONSTRAINT fk_person_address FOREIGN KEY (persion_address_id) REFERENCES address (addressId)
)
create table Address ( addressId bigint not null primary key )

7.2.2. one to one

A unidirectional one-to-one association on a foreign key is almost identical. The only difference is the column unique constraint.

<class name="Person"><id name="id" column="personId"><generator class="native"/></id><many-to-one name="address"column="addressId"unique="true"not-null="true"/></class><class name="Address"><id name="id" column="addressId"><generator class="native"/></id></class>
create table Person ( personId bigint not null primary key, addressId bigint not null unique )create table Address ( addressId bigint not null primary key )

A unidirectional one-to-one association on a primary key usually uses a special id generator. (Notice that we've reversed the direction of the association in this example.)

<class name="Person"><id name="id" column="personId"><generator class="native"/></id></class><class name="Address"><id name="id" column="personId"><generator class="foreign"><param name="property">person</param></generator></id><one-to-one name="person" constrained="true"/></class>
create table Person ( personId bigint not null primary key )create table Address ( personId bigint not null primary key )

7.2.3. one to many

A unidirectional one-to-many association on a foreign key is a very unusual case, and is not really recommended.

<class name="Person"><id name="id" column="personId"><generator class="native"/></id><set name="addresses"><key column="address_person_id"not-null="true"/><one-to-many class="Address"/></set></class><class name="Address"><id name="id" column="addressId"><generator class="native"/></id></class>
create table Person ( personId bigint not null primary key )
create table Address ( addressId bigint not null primary key, address_person_id bigint not null )
alter table Address address_persion_id ADD CONSTRAINT fk_address_person FOREIGN KEY(address_person_id)
REFERENCES person(personId);

We think it's better to use a join table for this kind of association.

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Hibernate 主鍵關(guān)聯(lián)中的一對(duì)一關(guān)聯(lián)
Hibernate 一對(duì)多外鍵雙向關(guān)聯(lián)
hibernate總體介紹
Object-relation mapping without the container
JPA將查詢結(jié)果轉(zhuǎn)換為DTO對(duì)象
SQL,從熟練到掌握
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服