cancel
Showing results for 
Search instead for 
Did you mean: 

How to define PK as auto-generated in EJB?

former_member186148
Active Participant
0 Kudos

Hello SDN!

I have several tables in Java Dictionary. Every table have a field called "id" (type string (32)) witch must be an auto-generated PK.

I can't find in bean settings how I can define these PK's as auto-generated. How I can do it?

It doesn't necessary for me to use number sequences like 1,2,3...

I'm usingCMP beans.

Regards,

Lev

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Lev,

you need to set the ID explicitly, there are no such implicit settings for EJB. I've seen some additional java components for to solve this issue, but none of them is pure Java and in most cases it is Database vendor dependent. So the easiest way is to implement your own incrementing routine, or some routine to generate unique IDs, not accending only.

For some inspiration how to do an GUID routine please see this link:

/message/2648947#2648947 [original link is broken]

regards,

mz