cancel
Showing results for 
Search instead for 
Did you mean: 

error with ejbFindByPrimaryKey(..) and primary key memeber called "pk"

Former Member
0 Kudos

Hello,

I've downloaded <i>Sneak Preview SAP NetWeaver 04 Slim Edition SP 11</i> and tested some code examples like <i>CalculatorDic</i> or <i>QuickCarRental</i>.

Then I started my own test application with person and activity entity beans to evaluate NetWeaver.

I think that I've found a bug:

If you create your person entity bean with a member called <b>pk</b> as the primary key field then you the method <b>ejbFindByPrimaryKey(pk)</b> will produce a

<i>com.sap.engine.services.ejb.exceptions.BaseObjectNotFoundException: The requested object does not exist.</i>

If you rename you primary key <b>pk</b> to i.e. <b>id</b>, then everything is ok.

I checked this with the <i>QuickCarRental</i> example and renamed one of the primary keys <b>bookingId</b> in <i>QuickBookingBean.java</i> to <b>pk</b> and had the same effect.

I look into the generated classes of my <i>PersonBean.java </i> after deployment and found where the problem is:

In <i>PersonBean0Persistent.java</i> the init() method looks like:


    public void init(Object pk) {
    id = (java.lang.String)pk;
  }

When I rename the primary key member <b>id</b> to <b>pk</b> then the same generated method looks like:


    public void init(Object pk) {
    pk = (java.lang.String)pk;
  }

But it should be:


    public void init(Object pk) {
    this.pk = (java.lang.String)pk;
  }

As you can see the member is <i>shadowed</i> by the lokal variable!

Can anyone reproduce or confirm this? Are there any fixes for?

Our main J2EE application with over 50 entities and session beans runs perfectly under IBM WebSphere, OC4J and JBoss.

The big problem is that all of our primary keys are called <b>pk</b> and that in case of using SAP's App. Server we have to change the primary key member of our beans!!

In my opinion SAP isn't Java conform yet!

regards

Jamal

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Jamal,

What you found out was really an issue in Web AS Java. However, it was fixed already some time ago in SP13. So, the solution for you is to upgrade.

Last but now least, it seems to be a bit too strong to claim that SAP is not J2EE-compliant judging by issue like that. SAP Web AS Java 6.40 is J2EE 1.3 compliant!

Regards, Victoria