有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在weblogic中使用hibernate代替eclipselink?

我在jboss服务器上安装了一个应用程序,实际上正在使用hibernate-jpa-2.0,当我试图在weblogic上运行这个应用程序时,我看到eclipselink中关于jpa注释的错误。我认为在这种情况下,我有两个选择,将我的应用程序更改为eclipselink或在weblogic中使用hibernate。问题是,如何在weblogic应用程序中声明。xml/weblogic。xml使用hibernate而不是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.


共 (1) 个答案

  1. # 1 楼答案

    您需要从weblogic部署描述符引用hibernate库(如果捆绑包是war,则为weblogic.xml;如果捆绑包是ear,则为weblogic-application.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>