Search code examples
javastored-proceduresjdbcweblogicopenjpa

OpenJPA and stored procedures, Weblogic 12c


Kinda specific question, but this is what I'm struggling with.

I used OpenJPA 1.2.3 on Weblogic 11g, calling stored procedures on a Sybase database. Used the com.sybase.jdbc2.jdbc.SybDriver. Recently we upgraded to the Weblogic 12c, and that configuration didn't work as well as hoped. When excecuting the application that performed the stored procedure call, it gave

javax.persistence.PersistenceException: java.lang.AbstractMethodError: weblogic.jdbc.wrapper.DatabaseMetaData_com_sybase_jdbc2_jdbc_SybDatabaseMetaData.getDatabaseMajorVersion() 

Upgraded to a newer driver com.sybase.jdbc4.jdbc.SybDriver

Now I get

org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: JZ0S8: An escape sequence in a SQL Query was malformed: '{call mydb..my_stored_procedure @input=?'. Error Code: 0 at
weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:117) at

Full stacktrace can be provided if necessary.

My entity:

package com.example.ejb.entities;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;

@Entity
@NamedNativeQuery(name="my_stored_procedure",
        query="{call mydb..my_stored_procedure @input=?}",
        resultClass=EntityJPA.class)
public class EntityJPA implements Serializable{

  private static final long serialVersionUID = 1L;

  @Id
  @Column(name="id")
  private String id;

  @Column(name="input")
  private int input;

  @Column(name="statuscode")
  private String statuscode;

  @Column(name="statusdescription")
  private String statusdescription;

  public String getStatuscode() {
    return statuscode;
  }

  public void setStatuscode(String statuscode) {
    this.statuscode = statuscode;
  }

  public String getStatusdescription() {
    return statusdescription;
  }

  public void setStatusdescription(String statusdescription) {
    this.statusdescription = statusdescription;
  }

  public int getInput() {
    return input;
  }

  public void setInput(int input) {
    this.input = input;
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

}

This worked as a charm on WebLogic 11g.

Can anyone point me to the right direction so this error can be resolved?


Solution

  • It looks to me like the ?} sequence is getting munged, based on the lack of closing brace in the error message. Try a) separating them somehow, or b) using a named parameter notation like :input instead of ?.