A primary key generator is "good" when it generates unique keys. Otherwise it's defective. The most common cause of failure is in multi-threaded systems where the process isn't atomic and the same key can be generated twice because the internal value wasn't updated before another request came in.
The easiest generation technique is just to use an integer and increment it for each new row added to the table. Many DBMS's have the ability to do this for you automatically.
When working with CMP
EJB's, there's a problem with this, though, since CMP EJBs expect ALL values for a newly-created EJB to be supplied by the constructor and not acquired from the DBMS. TO get around this, I use a special EJB that has a "createNewKey()" method. Because it's an EJB, the atomicity of the operation is ensured by the EJB transaction mechanism.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.