Submitted by sneha on Wed, 11/13/2013 - 03:32
Hibernate uses some strategies for saving an inheritance hierarchy of classes created in Java to the databases like SINGLE_TABLE, TABLE_PER_CLASS and JOINED. We use @Inheritance annotation over the entity class to specify the inheritance strategy. We specify the inheritance strategy by assigning a strategy from the InheritanceType enumeration to the strategy parameter of the @Inheritance annotation. Strategies defined in the InheritanceType enumeration are InheritanceType.SINGLE_TABLE, InheritanceType.TABLE_PER_CLASS and InheritanceType.JOINED.
Submitted by sneha on Wed, 11/13/2013 - 03:30
Hibernate uses some strategies for saving an inheritance hierarchy of classes created in Java to the databases like SINGLE_TABLE, TABLE_PER_CLASS and JOINED. We use @Inheritance annotation over the entity class to specify the inheritance strategy. We specify the inheritance strategy by assigning a strategy from the InheritanceType enumeration to the strategy parameter of the @Inheritance annotation. Strategies defined in the InheritanceType enumeration are InheritanceType.SINGLE_TABLE, InheritanceType.TABLE_PER_CLASS and InheritanceType.JOINED.
Submitted by sneha on Wed, 11/13/2013 - 03:29
An entity class in hibernate can refer to other entity classes or embed value types. An entity is a type on its own and has an existence of its own like a Course and its students. A value type is a type which doesn't have existence of its own, but belongs to an entity like a user and his address. Value types are always completely owned by their containing entity. Once you delete the entity, its associated value types are also deleted. But when you delete an entity, referenced entities still exist: when you delete a Course entity, you don't delete all its students.
Submitted by sneha on Wed, 11/13/2013 - 03:24
When mapping two entities, we annotate both classes as @Entity and the mapping type is specified as @OneToOne, @OneToMany, @ManyToOne or @ManyToMany over the declaration of one entity class in the other entity class. In Many-To-Many mapping, we refer to a collection/list of the entity from another entity and vice versa; and used @ManyToOne annotation on declarations of both entity collections.
Submitted by sneha on Wed, 11/13/2013 - 03:22
When mapping two entities, we annotate both classes as @Entity and the mapping type is specified as @OneToOne, @OneToMany, @ManyToOne or @ManyToMany over the declaration of one entity class in the other entity class. In One-To-Many mapping, we refer to a collection/list of the entity from another entity and mark the reference variable as @OneToMany. The opposite of this relation from the second entity to the first will be Many-To-One and is annotated as @ManyToOne. The example will make things more clear.
Pages