简体   繁体   English

OpenJPA和存储过程,Weblogic 12c

[英]OpenJPA and stored procedures, Weblogic 12c

Kinda specific question, but this is what I'm struggling with. Kinda特有的问题,但这是我在努力的问题。

I used OpenJPA 1.2.3 on Weblogic 11g, calling stored procedures on a Sybase database. 我在Weblogic 11g上使用了OpenJPA 1.2.3,在Sybase数据库上调用了存储过程。 Used the com.sybase.jdbc2.jdbc.SybDriver . 使用com.sybase.jdbc2.jdbc.SybDriver Recently we upgraded to the Weblogic 12c, and that configuration didn't work as well as hoped. 最近,我们升级到了Weblogic 12c,该配置无法达到预期的效果。 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 升级到更新的驱动程序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. 如有必要,可以提供完整的stacktrace。

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. 这在WebLogic 11g上具有吸引力。

Can anyone point me to the right direction so this error can be resolved? 谁能指出我正确的方向,以便可以解决此错误?

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 ? 尝试a)以某种方式将它们分开,或b)使用诸如:input而不是?的命名参数符号 .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM