Hibernate
@OneToManyのサンプル 一人(1)が複数(N)のアドレスを持つ。 <hibernate-configuration> <session-factory> </session-factory></hibernate-configuration>
@ManyToOneのサンプル 複数の人(N)が同じ(1)のアドレスを持つ。 <hibernate-configuration> <session-factory> </session-factory></hibernate-configuration>
エンティティの単向関係 : 必ずAと通してBをアクセスする。 分類 単向1 ⇒ 1 : @OneToOne cascade fetch mappedBy orphanRemoval optional targetEntity 単向N ⇒ 1 : @ManyToOne cascade fetch optional targetEntity 単向1 ⇒ N : @OneToMany cascade fetch m…
Mapを持つ永続化クラスの保存サンプル。 キーのAnnotaion @ElementCollection @ColletionTable @Column @MapKeyColumn 1. hibernate.xml
Setを持つ永続化クラスの保存サンプル。 キーのAnnotaion @ElementCollection @ColletionTable @Column @OrderColumn ※ Listとは異なるのは、Setは順序がなく重複を許さないため、@OrderColumnは不要である! ※ SetのIFのみ使え、実装は使えない。 1. hibe…
Listを持つ永続化クラスの保存サンプル。 キーのAnnotaion @ElementCollection @ColletionTable @Column @OrderColumn 1. hibernate.xml
参考:第10章 オブジェクトを扱う 永続化クラスの要件 パラメータなしのコンストラクター ID属性 setter,getter 非finalクラス equals(), hashCode() 永続化オブジェクトの状態 Transient : newした状態 Persistent : sessionスコープにある Detached : Pers…
Hibernateの永久化クラスの操作はSessionFactoryを離れない。 SessionFactoryはConfigurationオブジェクトから生成され、逆にConfigurationの唯一の機能はSessionFactoryに生成であり、生成後は破棄される。 Configurationの三つの生成方法 hibernate.proper…
設定ファイル : hibernate.cfg.xml <hibernate-configuration> <session-factory> </session-factory></hibernate-configuration>