Ask

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


Answer

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









나의 경우 entity와 실제 table를 매핑 시키지 않았음. 그래서 다음처럼 매핑 시킴

< before >

@Entity
public class SomeEntity {
    ...
}


< after >

@Entity
@Table(name="tableName")
public class SomeEntity {
    ...
}


Posted by linuxism
,