EclipseLink在PostgreSQL上使用未知数据类型

时间:2016-12-22 17:41:43

标签: java jpa orm eclipselink

在数据库中创建表的过程中,EclipseLink使用的类型为VARCHAR2,它不存在。我搜索过,并没有发现任何关于此类型或抛出的异常。

[EL Info]: connection: 2016-12-22 15:18:30.78--ServerSession(1814827909)--Thread(Thread[main,5,main])--/file:/home/lucas/workspace/jpalearning/target/classes_123 login successful
[EL Fine]: sql: 2016-12-22 15:18:45.834--ServerSession(1814827909)--Connection(1336437944)--Thread(Thread[main,5,main])--CREATE TABLE employee (DEPT VARCHAR2(32) NULL, ID NUMBER(19) NOT NULL, FULLNAME VARCHAR2(255) NULL, PRIMARY KEY (ID))
[EL Fine]: sql: 2016-12-22 15:18:45.835--ServerSession(1814827909)--Thread(Thread[main,5,main])--SELECT 1 FROM DUAL
[EL Warning]: 2016-12-22 15:18:45.836--ServerSession(1814827909)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: type "varchar2" does not exist
  Position: 29
Error Code: 0

Call: CREATE TABLE employee (DEPT VARCHAR2(32) NULL, ID NUMBER(19) NOT NULL, FULLNAME VARCHAR2(255) NULL, PRIMARY KEY (ID))
Query: DataModifyQuery(sql="CREATE TABLE employee (DEPT VARCHAR2(32) NULL, ID NUMBER(19) NOT NULL, FULLNAME VARCHAR2(255) NULL, PRIMARY KEY (ID))")
2016-12-22 15:18:45 DEBUG JpaTransactionManager:371 - Opened new EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@6d293993] for JPA transaction
2016-12-22 15:18:45 DEBUG JpaTransactionManager:403 - Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect$EclipseLinkConnectionHandle@6ffd4c0d]
[EL Fine]: sql: 2016-12-22 15:18:45.963--ClientSession(1576408634)--Connection(758201484)--Thread(Thread[main,5,main])--INSERT INTO employee (DEPT, ID, FULLNAME) VALUES (?, ?, ?)
    bind => [Textile, 2, Ravi Raj]
[EL Fine]: sql: 2016-12-22 15:18:45.965--ClientSession(1576408634)--Thread(Thread[main,5,main])--SELECT 1 FROM DUAL
[EL Warning]: 2016-12-22 15:18:45.966--UnitOfWork(48589645)--Thread(Thread[main,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: relation "employee" does not exist
  Position: 13
Error Code: 0

的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.lucas</groupId>
  <artifactId>jpalearning</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>jpalearning</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>

        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.github.willilucas</groupId>
            <artifactId>utils</artifactId>
            <version>fafec16</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>4.3.3.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>4.3.3.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>4.3.3.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.3.3.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.3.3.RELEASE</version>
        </dependency>


        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.9-atlassian-1</version>
        </dependency>

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4-redhat-2</version>
        </dependency>

        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>3.2.4</version>
        </dependency>

        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.1.0</version>
        </dependency>
 <!--  
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final-redhat-1</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.2.5.Final</version>
        </dependency>

 -->

        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.6.2</version>
        </dependency>

 <!--  
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.0</version>
        </dependency>

 -->

       <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4.1208-jdbc42-atlassian-hosted</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

  </dependencies>

  <repositories>

    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>

    <repository>
        <id>jBoss-releases-repository</id>
        <name>JBoss Releases Repository</name>
        <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
    </repository>

    <repository>
        <id>atlassian-3rd-party-repository</id>
        <name>Atlassian 3rd-Party Repository</name>
        <url>https://maven.atlassian.com/3rdparty/</url>
    </repository>

    <repository>
        <id>redhat-ga-repository</id>
        <name>Redhat GA Repository</name>
        <url>https://maven.repository.redhat.com/ga/</url>
    </repository>

  </repositories>

</project>

的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_2_0.xsd"
    version="2.0">

    <persistence-unit name="123" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

        <mapping-file>META-INF/jpa/orm.xml</mapping-file>

        <class>com.lucas.jpalearning.Employee</class>

        <properties>

            <!-- Java Database Connection Specific Properties -->

            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/lucas" />
            <property name="javax.persistence.jdbc.username" value="lucas" />
            <property name="javax.persistence.jdbc.password" value="123456" />

            <!-- Hibernate Specific Properties -->
            <!-- 
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="hibernate.archive.autodetection" value="class" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            -->

            <!-- EclipseLink Specific Properties -->
            <property name="eclipselink.ddl-generation" value="create-tables"/>
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>
            <property name="eclipselink.logging.level" value="FINE"/>
            <property name="eclipselink.weaving" value="false"/>


        </properties>
    </persistence-unit>
</persistence>

0 个答案:

没有答案