我如何在 weblogic 中使用 hibernate 而不是 eclipselink?

how can i use hibernate instead eclipselink in weblogic?

我有一个应用程序在 jboss 服务器上运行,实际上正在使用 hibernate-jpa-2.0,当我尝试 运行 Weblogic 上的这个应用程序时,我看到来自 eclipselink 的错误关于JPA 注释。我认为在这种情况下有两个选择,将我的应用程序更改为 eclipselink 或在 weblogic 中使用 hibernate。问题是,我如何在我的 weblogic-application.xml / weblogic.xml 中声明使用休眠而不是 eclipselink。这个有可能 ?发生的错误如下:

Substituted for missing class Exception [EclipseLink-7298] (Eclipse Persistence Services - 2.6.5.v20170607-b3d05bd) - org.eclipse.persistence.exceptions.ValidationException Exception Description: The mapping [associado] from the embedded ID class [class br.com.project.web.model.associate.pk.AssociateMaintainPK] is an invalid mapping for this class. An embeddable class that is used with an embedded ID specification (attribute [.AssociateMaintainPK] from the source [class br.com.project.web.model.associate.AssociateMaintain]) can only contain basic mappings. Either remove the non basic mapping or change the embedded ID specification on the source to be embedded.

您需要从您的 weblogic 部署描述符中引用您的休眠库(如果您的包是 war 或 weblogic-application.xml ear,则 weblogic.xml ).如果部署在同一个 weblogic 实例上的多个应用程序使用,则部署与您的应用程序共存的库或作为一组共享库(这是我使用的解决方案)。这样 WLS 将使用引用的库而不是与 weblogic 捆绑的默认实现(EclipseLink for JPA api)。

<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd 
    http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.8/weblogic-web-app.xsd">
... config stuff
<!-- hibernate orm -->
<library-ref>
    <library-name>hibernate-core</library-name>
</library-ref>
<library-ref>
    <library-name>hibernate-entitymanager</library-name>
</library-ref>
<library-ref>
    <library-name>hibernate-envers</library-name>
</library-ref>
<library-ref>
    <library-name>hibernate-jpa-2.1-api</library-name>
</library-ref>
<!-- hibernate orm deps -->
<library-ref>
    <library-name>dom4j</library-name>
</library-ref>
<library-ref>
    <library-name>hibernate-commons-annotations</library-name>
</library-ref>
<library-ref>
    <library-name>jboss-logging</library-name>
</library-ref>
<library-ref>
    <library-name>jboss-logging-annotations</library-name>
</library-ref>
<library-ref>
    <library-name>jandex</library-name>
</library-ref>
<library-ref>
    <library-name>javassist</library-name>
</library-ref>