[4]. JPAエンティティ継承関係
今回は単一テーブル戦略について知りたい.
前の文章では、3つのエンティティを作成しました.
ddl作成は1つのCREATEのみ実行されます.
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
シングルテーブル戦略の使用を指定します.
親テーブルのすべての子エンティティフィールドが連結されています.
それでは今回もアルバムに登録してみましょう.
登録
ITEMテーブル.
単一の表の特徴から見ると、
1.JOIN不要、照会機能がJOINより速い
2.クエリーが簡単です.
サブエンティティマッピングのカラムはすべて空にできます.
4.すべてのものを保存すると、テーブルが大きくなる可能性があります.データが多くなると遅くなります.
前の文章では、3つのエンティティを作成しました.
ddl作成は1つのCREATEのみ実行されます.
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
シングルテーブル戦略の使用を指定します.
create table item (
dtype varchar(31) not null,
id bigint not null auto_increment,
name varchar(255),
price integer not null,
artist varchar(255),
actor varchar(255),
director varchar(255),
primary key (id)
) engine=InnoDB
単一のテーブルポリシーは、親テーブル、すなわち親テーブルのエンティティのみを生成します.親テーブルのすべての子エンティティフィールドが連結されています.
それでは今回もアルバムに登録してみましょう.
登録
Hibernate:
insert
into
item
(name, price, artist, dtype)
values
(?, ?, ?, 'A')
Hibernate:
select
album0_.id as id2_0_0_,
album0_.name as name3_0_0_,
album0_.price as price4_0_0_,
album0_.artist as artist5_0_0_
from
item album0_
where
album0_.id=?
and album0_.dtype='A'
アルバムIDとサブテーブル区切り記号を使用して検索します.ITEMテーブル.
単一の表の特徴から見ると、
1.JOIN不要、照会機能がJOINより速い
2.クエリーが簡単です.
サブエンティティマッピングのカラムはすべて空にできます.
4.すべてのものを保存すると、テーブルが大きくなる可能性があります.データが多くなると遅くなります.
Reference
この問題について([4]. JPAエンティティ継承関係), 我々は、より多くの情報をここで見つけました https://velog.io/@akar97/3.-JPA-엔티티-상속-관계-sbilnamkテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol