Please use the google group to ask questions - thanks.

by golivier 23 Sep 12:21
how use @GeneratedValue

Hi,

How use the annotation @GeneratedValue(strategy = GenerationType.TABLE)

It's implemented ?

How I can create an generator id for replace this :

select max(id) as maxId from table;
bean.id = maxId+1

is not implemented what I think?

best regards
Olivier

30 Sep 09:22
by Rob

You are right. That is not implemented.

Do you really want to do that though?

The reason I ask is every database I use has good internal support for generating identities (identity/autoincrement or sequences).

These are HIGHLY recommended due to:
1. performance
2. allows any other application (non-java or whatever) to also insert into the database and interact nicely.

There are two problems with the select max(..) approach.
1. performance (its not going to be great in comparison)
2. You have a locking problem (multiple max queries occur then inserts... and you have the same ids)

Can you let me know why you want to use the select max(id) etc?
I'm guessing you want no gaps in your id's?
Which DB are you using?


Cheers, Rob.

Create a New Topic

Title:
Body:
 
Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse