Hi,
i got a table Company, wicht its id is an auto_increment field.

As the companyBean has a CMR field, i try set those in ejbPostCreate(), but i never 
get till there because i get the following excetion.

ERROR [STDERR] javax.ejb.CreateException: Primary key for created instance is null.

I think it's because i'm not passing the PK as an argument (as it's auto_increment).

What should i do to make this work???

Here are my create and postCreate methods.

  |     /**
  |      * The  ejbCreate method.
  |      * 
  |      * @ejb.create-method 
  |      */
  |     public java.lang.Integer ejbCreate(String fantasyName, String socialReasonName,
  |                                                                        String 
cnpj, String type, AddressVO addressVO) throws javax.ejb.CreateException {
  |                                                                             
  |             // EJB 2.0 spec says return null for CMP ejbCreate methods.
  |             
  |             System.out.println("Entrando em CompanyBean.ejbCreate()");
  |             
  |             //setCompanyID(companyID);
  |             setFantasyName(fantasyName);
  |             setSocialReasonName(socialReasonName);
  |             setCnpj(cnpj);
  |             setType(type);  
  |             
  |             System.out.println("Saindo CompanyBean.ejbCreate()"); 
  |             
  |             //Observe q nao ha necessidade de retornar a chave primaria (como em 
BMPs), 
  |             //pois o container pode acessar a chave primaria atraves dos campos 
cmp-field.
  |             return null;
  |     }
  |     
  |     /**
  |      * 
  |      * The container invokes this method immediately after it calls ejbCreate.
  |      * 
  |      */
  |     public void ejbPostCreate(String fantasyName, String socialReasonName,
  |                                                       String cnpj, String type, 
AddressVO addressVO) throws javax.ejb.CreateException {
  |             
  |             System.out.println("entrando em postCreate");
  |             AddressLocalHome addressLocalHome = null;
  |             try {
  |                     InitialContext ic = new InitialContext();
  |                     addressLocalHome = 
(AddressLocalHome)ic.lookup(AddressLocalHome.JNDI_NAME);
  |             } catch (NamingException e) {
  |                     // TODO Auto-generated catch block
  |                     e.printStackTrace();
  |             }
  |                     
  |             AddressLocal addressLocal = addressLocalHome.createByVO(addressVO);    
 
  |             this.setAddress(addressLocal);                                         
 
  |                                                                                    
         
  |     }


Thanks,
ltcmelo






View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3837327#3837327

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3837327



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to