Websphere 上的 EntityManagerFactory 错误

发布于 2024-08-19 22:44:09 字数 3091 浏览 0 评论 0原文

我有一个非常奇怪的问题。 有一个使用 Hibernate 和 spring 的应用程序。我定义了一个使用 JNDI 查找的实体管理器。它看起来像这样

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="persistenceUnitName" value="ConfigAPPPersist" />
    <property name="jpaVendorAdapter">
        <bean
            class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="true" />
            <property name="generateDdl" value="false" />
            <property name="databasePlatform"
                value="org.hibernate.dialect.Oracle9Dialect" />

        </bean>
    </property>

</bean>

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
    <property name="targetDataSource">
        <bean
            class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="jdbc/pmp" />
        </bean>
    </property>
</bean>

这个应用程序在 DEV 中运行良好。 但是,当我们转移到更高的环境时,部署此应用程序的团队最初成功地完成了它,但在应用程序重新启动几次后,实体管理器开始出现此问题

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: ConfigAPPPersist] Unable to build EntityManagerFactory 
     at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677) 
     at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132) 
     at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224) 
     at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) 
     ... 32 more 
     Caused by: org.hibernate.MappingException: **property mapping has wrong number of columns**: com.***.***.jpa.marketing.entity.MarketBrands.$performasure_j2eeInfo type: object

现在您会说这很明显实体 MarketBrands 是不正确的。但它不是它映射到表就好了。相同的代码也适用于 DEV。

此外,jndi 不可能不正确,因为它最初部署并工作正常,但在重新启动后会抛出此错误。

这很奇怪而且不太符合逻辑。 但如果有人遇到过这个问题或者有任何想法可能导致这个问题!! help

持久性单元的 persistence.xml 几乎没有

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

    <persistence-unit name="ConfigAPPPersist">
    <!--    commented code
        --> 
    </persistence-unit>

</persistence>

I have a very weird problem.
Have an application using Hibernate and spring.I have an entitymanger defined which uses a JNDI lookup .It looks something like this

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="persistenceUnitName" value="ConfigAPPPersist" />
    <property name="jpaVendorAdapter">
        <bean
            class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="true" />
            <property name="generateDdl" value="false" />
            <property name="databasePlatform"
                value="org.hibernate.dialect.Oracle9Dialect" />

        </bean>
    </property>

</bean>

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
    <property name="targetDataSource">
        <bean
            class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="jdbc/pmp" />
        </bean>
    </property>
</bean>

This application runs fine in DEV.
But when we move to higher envs the team that deploys this application does it successfully initially but after a few restarts of the application the entitymanager starts giving this problem

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: ConfigAPPPersist] Unable to build EntityManagerFactory 
     at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677) 
     at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132) 
     at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224) 
     at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) 
     ... 32 more 
     Caused by: org.hibernate.MappingException: **property mapping has wrong number of columns**: com.***.***.jpa.marketing.entity.MarketBrands.$performasure_j2eeInfo type: object

Now you would say this is pretty obvious the entity MarketBrands is incorrect. But its not it maps to the table just fine. And the same code works on DEV.

Also the jndi cannot be incorrect since it deploys and works fine initially but throws uo this error after a restart.

This is weird and not very logical.
But if someone has faced this or has any idea on what might be causing this Please!! help

The persistence.xml for the persitence unit has very little

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

    <persistence-unit name="ConfigAPPPersist">
    <!--    commented code
        --> 
    </persistence-unit>

</persistence>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉生梦死 2024-08-26 22:44:09

MarketingBrands 是否有 Object 属性?如果是,请尝试将其更改为可序列化(如果这是不可能的,因为该字段存在,因为代码已由 PeformaSure 检测,那么除了“打开一个票”与 Quest)。

Does the MarketingBrands have an Object property? If yes, try to change it to Serializable (and if this is not possible because the field if there because the code has been instrumented by PeformaSure, then I don't have any other solution than "open a ticket" with Quest).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文