For CMP beans see the thread NEW FEATURE: new ways to create entity beans.
For BMP, I am not sure about a nice way to do it. You should learn the api of the driver you use and you'll face many problems.
I would recommend you to use key generator. UUIDKeyGenerator is available in JBoss since 3.2 version. It generates 32 bit length uuid's. You can use it or implement your own key generator.