- SINGLE_TABLE (default)
- JOINED
- TABLE_PER_CLASS
Showing posts with label Embeded. Show all posts
Showing posts with label Embeded. Show all posts
Monday, January 2, 2012
Inheritance Mapping
Basically there are 3 types of inheritance mapping. We may use those methods suitably.
Labels:
Annotations,
Embeded,
Hibernate,
Inheritance,
JPA,
Mapping,
Mysql
Sunday, January 1, 2012
Compound Primary Keys in HIBERNATE
Most of the time we need only 1 primary key. But there are some situations we may need compound primary keys.
Here in hibernate it is simple. We can use 2 classes into 1 table strategy.
Here in hibernate it is simple. We can use 2 classes into 1 table strategy.
Account.java
import javax.persistence.Entity; import javax.persistence.Id; @Entity public class Account { private AccountCompoundKey compoundKey; private int accBalance; @Id public AccountCompoundKey getCompoundKey() { return compoundKey; } public void setCompoundKey(AccountCompoundKey compoundKey) { this.compoundKey = compoundKey; } public int getAccBalance() { return accBalance; } public void setAccBalance(int accBalance) { this.accBalance = accBalance; } }
Labels:
Annotations,
Compound Primary Key,
Embeded,
Hibernate,
JPA,
Mysql
Saturday, December 31, 2011
One table for 2 or More Classes
In some situations we may need create 1 table out of 2 or more classes. for instance when we map inheritance.
New Annotations :
New Annotations :
- @Embeddable : when a class is going to be embedded inside another persistence class we have to annotate the class as embeddable
- @Embedded : When some (object) field is going to persist inside a class. The object type must annotated as embeddable
Labels:
Annotations,
Embeded,
Hibernate,
JPA,
Mysql,
Primary Key
Subscribe to:
Posts (Atom)