开发者

EntityManagerFactory error on Websphere

开发者 https://www.devze.com 2022-12-19 09:12 出处:网络
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

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.Ejb3Con开发者_高级运维figuration.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>


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消