To answer my own question, it works. That covers the technical part. 
Still wondering, it is good practice to do so? This is the code:
 
 public Long ejbCreate(String userNickName, String codeId, Integer 
gadgetId, Integer value)
    throws RemoteException, CreateException{
   
    if (Globals.DEBUG) {
        System.out.println("Transaction.create() --- entry");
        System.out.println(" userNickName: " + userNickName);
        System.out.println(" codeId: " + codeId);
        System.out.println(" gadgetId: " + gadgetId);
        System.out.println(" value: " + value);
    } // end of if (Globals.DEBUG)
   
    //
    // get the new id from the Sequence bean
    //
    Sequence sequence = null;
    try{
        String name = "java:/comp/env/ejb/Sequence";
        InitialContext initialContext = new InitialContext();
        Object ref = initialContext.lookup(name);
        Class classType = SequenceHome.class;
        SequenceHome sequenceHome =
        (SequenceHome)PortableRemoteObject.narrow(ref, classType);
        sequence = sequenceHome.findByPrimaryKey("Transaction");
    }
    catch(Exception e){
        if (Globals.DEBUG) {
        String methodName = "Transaction.create()";
        System.out.println("Exception in " + methodName);
        System.out.println("  exception: " + e);
        System.out.println("  message:  " + e.getMessage());
        } // end of if (Globals.DEBUG)
       
        throw new CreateException();
    }

    this.id = sequence.getSize();
    this.userNickName = userNickName;
    this.codeId = codeId;
    this.gadgetId = gadgetId;
    this.value = value;
    this.lastModified = new Timestamp( System.currentTimeMillis() );

    sequence.incrementSize();
    return null;
    }
 

Marcel Schepers wrote:

>Hello,
>
>Is it allowed to make a internal B2B call inside the ejbCreate
>method. I have a CMP entity bean whose primary key is a Long
>value. The new Long value is stored in a separate table with a
>separate entity bean. While creating the bean I would like to make a
>call to get the new primary key of the bean to be created?
>
>Thanks,
>Marcel
>
>
>_______________________________________________
>JBoss-user mailing list
>[EMAIL PROTECTED]
>http://lists.sourceforge.net/lists/listinfo/jboss-user
>
>




_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to