Kodo JDO generates incorrect sql query with additional unnecessary conditions (Doc ID 1404493.1)

Last updated on DECEMBER 06, 2012

Applies to:

Oracle Weblogic Server - Version 10.3.4 and later
Information in this document applies to any platform.

Symptoms

After upgrading the application from the WLS 10.3.0 to WLS 10.3.4, it is observed that the sql query generated by Kodo JDO becomes incorrect.

The entity EJB is defined as POJO.  The EJB is then added and defined in the main kodo.properties file. The build script runs through the Kodo PCEnhancerTask. The enhanced POJO/entity is packaged as a JAR file and added to the server classpath. The application that uses the EJB is deployed as a separate EAR file. The POJO is called from various places (eg. Message Driven Bean, web web application, or session bean) by the application in the EAR file.

The EJB uses inheritance, with base class, and subclass, code snippets as below -

public abstract class Port extends Element
{
  public static final String NO_SWITCH_TYPE = "None";
  private boolean defective;
  private PhysicalLink physicalLink;
}

public abstract class PhysicalLink extends Element
{
  private static final long serialVersionUID = 1L;
  private String aEndClli;
  private String zEndClli;
  private String icoreSecondaryCircuitId;
  private String icoreTelcoOCDCircuitId;
  protected PhysicalLinkType type;
  protected String adminState;
  public transient String newCID;

  public PhysicalLink(String id)
  { super(id); }
}


Code snippets of the application codes that uses PhysicalLink -

...
private Collection<String> getPortDescendentsOfElement(Element headElement)
{
  Collection<String> elements = new TreeSet<String>();
  Iterator iter = headElement.getChildrenIterator();
  while (iter.hasNext())
  {
    Element element = (Element) iter.next();
    if (Port.class.isInstance(element))
    {
      Port port = (Port) element;
      if (port.getPhysicalLink() != null)
      {
        if (!(port.getPhysicalLink() instanceof AturPLink)
        && !(port.getPhysicalLink() instanceof TrunkLink)
        && !(port.getPhysicalLink() instanceof MiniRamPLink))
        {
          Port opposingPort = port.getPhysicalLink().getOpposingPort(port);
          if (opposingPort != null && opposingPort.getNode() != null
          && opposingPort.getNode() instanceof AtmSwitch)
          {
            elements.add(port.getPhysicalLink().getClli());
          }
        }
      }
    }
    elements.addAll(getPortDescendentsOfElement(element));
  }
  return elements;
}
...


In WLS 10.3.0, Kodo debugs show the correctly generated query -

11344 TRACE [main] openjpa.jdbc.SQL - <t 23763868, conn 9950192> executing prepstmnt 20189571 SELECT t0.JDOCLASS, t0.JDOVERSION, t0.CLLI, t0.LATACLLI, t0.NMSNAMES_JDOID, t0.PARENT_JDOID, t0.PENDING, t0.STATECLLI, t0.STATUS, t1.AENDCLLI, t1.ADMINSTATE, t1.ICORESECONDARYCIRCUITID, t1.ICORETELCOOCDCIRCUITID, t1.TYPE0, t1.ZENDCLLI, t1.VPCALLOWED, t1.IMAGROUPID
FROM ELEMENT t0, PHYSICALLINK t1 WHERE t1.JDOID = ? AND t1.JDOID = t0.JDOID [params=(long) 239470320] [reused=0]


But in WLS 10.3.4, Kodo generates the following query -

3969 TRACE [main] openjpa.jdbc.SQL - <t 5965416, conn 25418390> executing prepstmnt 18489944 SELECT t1.JDOCLASS, t1.JDOVERSION, t1.CLLI, t1.LATACLLI, t1.NMSNAMES_JDOID, t1.PARENT_JDOID, t1.PENDING, t1.STATECLLI, t1.STATUS, t0.AENDCLLI, t0.ADMINSTATE, t0.ICORESECONDARYCIRCUITID, t0.ICORETELCOOCDCIRCUITID, t0.TYPE0, t0.ZENDCLLI, t0.VPCALLOWED, t0.IMAGROUPID
FROM PHYSICALLINK t0, ELEMENT t1 WHERE t1.JDOCLASS = ? AND t0.JDOID = ? AND t0.JDOID = t1.JDOID [params=(String) com.bellsouth.snt.broadbandos.network.topology.PhysicalLink, (long) 239470320] [reused=0]


The highlighted differences above show an extra string of  t1.JDOCLASS = ? AND in the WHERE clause.  In addition, the JDOID parameter input in  t1.JDOID = t0.JDOID  shows an extra String definition in WLS 10.3.4.

As a result of the incorrectly generated query by Kodo for the JDO, the EJB query fails in the application in WLS 10.3.4.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms