--- John Doe <[EMAIL PROTECTED]> wrote:
> Hi. I create row in DB through cmp and try to get
> it's id like this :
> Object ref = context.lookup("ContractLocal");
> ContractLocalHome contractLocal =
> (ContractLocalHome) ref;
> ret = contractLocal.create(contract).getId();
>
> but I get :
>
> 2007-06-25 14:44:02,384 ERROR
> [org.jboss.ejb.plugins.LogInterceptor]
> EJBException in method: public abstract
> java.lang.Integer
>
com.egar.chronim.server.ejb.SessionFacade.createContract(
> com.egar.chronim.model.Contract) throws
> java.rmi.RemoteException:
> javax.ejb.NoSuchObjectLocalException: Entity not
> found: primaryKey=0
>
> but row creates in DB. So I can't get Id through my
> local interface because
> EJB has id as 0. It does not increment like it does
> in DB.
> How can I get the real ID of new created row?
Thanks go to the EJB spec ;)
Short version is -your fresh and smelly EJB does not
get any ID until it is saved into database. You can
not
control when it saved into database - so you have no
possibility to reliably get ID of freshly created
entity
bean.
Back then in old days I actually used entity beans,
we created counter beans and received sequncial IDs
from there.
( Looks idiotic - but that's life and standarts ;) )
Good news is that such counter entity bean is really
transaction oriented and produces good IDs.
regards,
----[ Konstantin Pribluda http://www.pribluda.de ]----------------
JTec quality components: http://www.pribluda.de/projects/
____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
xdoclet-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user