为什么数据库Oracle 11g中的表不是由Hibernate创建的(通过Spring& Maven)?

时间:2015-08-03 16:51:20

标签: spring hibernate maven oracle11g

我无法连接到数据库而我找不到问题

持久性文件:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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://xmlns.jcp.org/xml/ns/persistence/persistence_2_0.xsd ">
  <persistence-unit name="UP_GAB" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name= "hibernate.show_sql" value= "true"/>
            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
        </properties>
    </persistence-unit>
</persistence>

contexte file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

        <bean id="datasource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
        <property name="connectionCachingEnabled" value="true"/>
        <property name="URL" value="jdbc:oracle:thin:localhost:1521:GAB"/>
        <property name="user" value="issam"/>
        <property name="password" value="*****"/>
</bean>

<bean id= "persistenceUnitManager" class= "org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
        <property name= "persistenceXmlLocations">
        <list>
        <value>classpath*:META-INF/persistence.xml</value>
        </list>
        </property>
        <property name= "defaultDataSource" ref= "datasource"></property>
</bean>
<bean id= "entityManagerFactory" class= "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name= "persistenceUnitManager" ref= "persistenceUnitManager"></property>
<property name= "persistenceUnitName" value= "UP_GAB"></property>
</bean>
<bean id="transactionManager" class= "org.springframework.orm.jpa.JpaTransactionManager">
<property name= "entityManagerFactory" ref= "entityManagerFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>

</beans>

数据库信息:

  

连接名称:Gab
  用户名:issam
  主机名:localhost
  港口:1521
  SID:Gab

这是pom.xml文件中的依赖项:

       <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.4.0</version>
        </dependency>

注意:我有Oracle 11 g而不是phpmyadmin

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

财产应该是:
property name =&#34; hibernate.hbm2ddl.auto&#34;值=&#34;创建&#34;