Yeah I found it..
I use auto increment fields in mysql. So I create an ejb in cmp, the cmp creates a record in db and everybody is happy, right? Not everybody, as soon as you do some modification on the newly created bean the pk is still missing in the bean. The cmp is not loading the db pk in and so this is still null. Hence the error messag.
with xdoclet the link above can be summarized as:
I think this is platform and db dependent. So in terms of portability maybe not the wisest choice.
solution 2 get rid of the autoincrement fields in db design, make an extra db table, with entity beannames and generate keys and whenever you do a create call this cmp (via a session or local and retrieve the value + 1), and have the db update the key for the corresponding value. DB and appserver independent.
I hope that both methods are cluster and thread save.
In fact the auto-gen-key option is not working..
After creation retrieval of the pk-field results in a class cast exception. java.lang.Long vs java.lang.Integer (as it is supposed to be). I havent been able to figure why this went wrong: The field representing the pk field goes nuts after querying, so the only thing remaining is this keygen table.