When to use @TableGenerator?
Can you tell me when 开发者_运维百科to use it and why should I create a new table just for keeping primary key while most DBMS now support auto increment and you can adjust it easily?
The major advantage of the TableGenerator
is portability, this is the only strategy that is guaranteed to work with any database. Another advantage is that table sequencing is fully transactional and permits truly sequential ids to be allocated (at the cost of performance and concurrency), if desired.
See also
- JPA wiki book
- Advanced Sequencing
精彩评论