简体   繁体   中英

how can i use hibernate instead eclipselink in weblogic?

I have an application wheeling in jboss server, and actually is using hibernate-jpa-2.0, when i tryied to run this app on the weblogic i see an error from the eclipselink about JPA annotations. I think am have two options in this case, change my application to eclipselink OR use hibernate in weblogic. The question is, how can i declare in my weblogic-application.xml / weblogic.xml to use hibernate and not the eclipselink. This is possible ? The error that is happening is as follows:

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.

You will need to reference your hibernate libraries from your weblogic deployment descriptor (either weblogic.xml if your bundle is a war or weblogic-application.xml for an ear ). Either deploy the libraries colocated with your app or as a set of shared libraries if used by multiple apps deployed on the same weblogic instance (this is the solution I use). This way WLS will use the library referenced instead of the default implementation bundled with 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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