Robert Hargreaves wrote:
> 
> Dear All
> 
> I have the following code in a Session bean, which deletes an Entity bean
> based on its Primary Key:
> 
>         int oid = 1386;
>         StubHome sthome = (StubHome)initialContext.lookup("StubHome");
>         try{
>                 PrimaryKey pk = new PrimaryKey(oid);
>                     sthome.
>         }catch(Exception e){
>                 throw new RemoteException(e.toString()+ ":"+
> Integer.toString(oid));
>          }
> 
> The program throws an javax.ejb.RemoveException:ObjectNotFound:1386.
> However if the code is changed to the following (with the same data in the
> database), the database record is found and deleted as intended.
> 
>         int oid = 1386;
>         StubHome sthome = (StubHome)initialContext.lookup("StubHome");
>         try{
>                 PrimaryKey pk = new PrimaryKey(oid);
>                     Stub stub = sthome.findByPrimaryKey(pk);
>                     stub.remove();
>          }catch(Exception e){
>                 throw new RemoteException(e.toString()+ ":"+
> Integer.toString(oid));
>          }
> 
> I am using Jonas 1.6 on NT.
> As far as I'm aware, sthome.remove(pk) worked fine with Jonas 1.5.
> This looks the same problem as
> http://192.44.60.125/messages/JonasUsers/0568.html
> 
> Any suggestions?
> 
> Regards
> 
> Robert Hargreaves.


Thank you Robert,
You are right there is a bug. 
In the current version (but it was the same in previous versions)
home.remove(pk) is not working when you want to remove an entityBean
whose instance has not been yet created in memory via a previous
findByPrimaryKey
or a create fonction.
This will be fixed soon.
For the moment the workaround is the one you propose or 

        int oid = 1386;
        StubHome sthome = (StubHome)initialContext.lookup("StubHome");
        
        PrimaryKey pk = new PrimaryKey(oid);
        Stub stub = sthome.findByPrimaryKey(pk);
        sthome.remove(pk);
Best regards,
-- 
        Philippe

Philippe Coq  Groupe Bulll/BullSoft/OpenMaster  Phone: (33) 04 76 29 78
49
Bull S.A  - 1 rue de Provence - 38432 Echirolles Cedex France
[EMAIL PROTECTED]  http://www-frec.bull.com
Download our EJBServer at http://www.bullsoft.com/ejb
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to