Cosminexus V9 アプリケーションサーバ 機能解説 基本・開発編(コンテナ共通機能)

[目次][用語][索引][前へ][次へ]

5.4.2 EntityManagerの種類

EntityManagerの種類には,コンテナ管理のEntityManagerおよびアプリケーション管理のEntityManagerの2種類があります。それぞれ説明します。

<この項の構成>
(1) コンテナ管理のEntityManager
(2) アプリケーション管理のEntityManager

(1) コンテナ管理のEntityManager

EntityManagerの作成や破棄をコンテナに任せる方法です。コンテナ管理のEntityManagerを使用すると,EntityManagerの生成や破棄を意識しないでアプリケーションをコーディングできます。コンテナ管理のEntityManagerを取得する方法と破棄する方法を説明します。

(2) アプリケーション管理のEntityManager

EntityManagerの作成や破棄をアプリケーションが明示的に行う方法です。アプリケーションのコードによって明示的にライフサイクルが管理されます。アプリケーション管理のEntityManagerを取得する方法と破棄する方法を説明します。