Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to build EntityManagerFactory

persistence.xml file

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
 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">

 <persistence-unit name="xyz" transaction-type="JTA">

  <provider>org.hibernate.ejb.HibernatePersistence</provider>
  <class>com......</class>
 </persistence-unit>

</persistence>

ApplicationContext.xml

<bean id="transactionManager"
    class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

 <bean id="dataSource"
     class="org.springframework.jdbc.datasource.DriverManagerDataSource">
     <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
     <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE" />
     <property name="username" value="yyy" />
     <property name="password" value="yyy" />
</bean>

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

<bean id="theDao" class="com.cin.the.dataaccess.dao.the.TheJPA">
    <property name="entityManagerFactory" ref="entityManagerFactory"></property>
 </bean>

the error i get is

[PersistenceUnit: xyz] Unable to build EntityManagerFactory

can any one tell me the mistake

like image 766
Rohan S Raju Avatar asked Jan 21 '23 16:01

Rohan S Raju


1 Answers

The main problem was that the entites was not generated properly. so at the end of the stacktrace it was giving this error

Caused by: org.hibernate.MappingException: property mapping has wrong number of columns: com......date type: object

once the entity was generated correctly the problem was solved

like image 140
Rohan S Raju Avatar answered Jan 24 '23 07:01

Rohan S Raju