cancel
Showing results for 
Search instead for 
Did you mean: 

CMP-EJB: How to get primary-key (automatically created one)

Former Member
0 Kudos

Hi group,

I have CMP-EJBs with autatically generated primary-keys.

I would like read this key - but unfortunatly there is no business-method to retrieve it (well - thats not surprising, the key is not considered as an CMP-field..)

Do you know, how to retrieve the key?

(I like to store it in my WebDynpro JavaBean to make later handling a bit easier...)

Thanks,

Simon

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This won't exactly solve your problem, but it's an alternative solution.

What you can do is generate your own keys instead of letting the DB do it for you. Declare your primary key in your CMP-EJB and then use a UUID key generator to generate keys and set them on creation of the EJB.

This will provide you with a method for retrieving the key.

kind regards,

Dion

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Simon,

I found a link about writing a primary key class for CMP-EJP.

http://www.devx.com/tips/Tip/17816

EJB-1.0 vs EJB-1.1

http://www.unix.org.ua/orelly/java-ent/ebeans/appd_01.htm

Hope it helps.

Regards,

Maheswaran.B

Former Member
0 Kudos

Thank you all for the suggestions!

I've just overseen the getPrimaryKey() method (because it is not generated in my beans) - it is simply inherited from an ejb base-class...

sorry and best regards,

Simon