Since Hibernate is popular, then now EJB 3.0 also has the similar mechanism. Here we usually have the strategies to generate it. I use EJB 3.0 as example and the concept you can apply universal.

1. Automatic Id generation

Need a Primary Key? Let Me Show You the Ways

2. Id generation using a table

TopLink JPA: Using a Table for Id generation

3. Id generation using a database sequence

Using Primary Keys with Java Persistence

4. Id generation using database identify

Automatic Primary Key Generation using Oracle, SQLServer, or SQLServer2000

5. Data modeling concept

Data Modeling 101

The Design of a Robust Persistence Layer For Relational Databases

How to avoid primary key collision on multiple sites?

6. Object-Relational patterns

Object-Relational Metadata Mapping Patterns

Object-Relational Structural Patterns

Object-Relational Behavioral Patterns

Advertisements