-
1. Re: Setting CMR fields
noel.rocher Mar 7, 2002 4:04 AM (in response to noel.rocher)just to put this thread on top
-
2. Re: Setting CMR fields
dsundstrom Mar 7, 2002 10:27 AM (in response to noel.rocher)> In a SessionBean (and in only one transaction), I:
> 1)- create a new Invoice
> 2)- create a new InvoiceLine
> 3)- add the new line with the
> he Invoice.getLines().add() method
>
> Is it wrong or this seems to be the rigth way ?
Yes
> Why this ejbPostCreate(){ setInvoice_id();}
> should be necessary ?
Read the cmp chapter in the EJB 2.0 spec. A bean provider is not allowed to set a cmr field in ejbCreate.
> Even worse the
> ejbPostCreate(){ lookup_for_Invoice_localhome +
> find_Invoice_by_primary_key + setInvoice(...);}
Cache the JNDI lookup somewhere in your application. JNDI lookups are very expensive.
Find by primary key is usually a single hashtable lookup, but if you want to make the code easier, pass the local invoice object.
> example I read in the Java Connection
> article(http://developer.java.sun.com/developer/techni
> alArticles/ebeans/EJB20CMP/)
I haven't
> Is someone can tell me what is the best practices for
> doing this ?
Doing what?