We're using auto-increment feature
so that we don't need to pass the pk value
in ejbCreate method.
So let's narrow my xample to the situation where I decided to use some stateless session bean to generate pk's.
(Is such a method used by you?)
then again should that session bean method getNextPk be invoked by cmp in its create method or pk_generation-session bean should be invoked earlier by a service session bean that is responsble for "adding rows" action?
I use Autonumber factory for auto-increment (just to keep things portable).
I enter ejbCreate() with no pk and call the factory.getNextInteger() in that method.
This works fine. So I imagine you can do the same with your session bean.
The rule is that before you leave ejbCreate you should have set your pk and no other fields (eg. setPk(sessionBean.getNextInteger())). If you need to set any other fields then you should set them in ejbPostCreate().
thanks, but one more equestion about that in ejbCreate only pk field should be set
(actually i recenlty read that in ejbPostCreate one should set CMR fields in ejbPostCreate not in ejbCreate)
you said that in ejbCreate only pk field
why not everything just in ejbCreate? is it a mater of style?
(maybe I am asking about something obvious :)