小编Umm*_*bal的帖子

如何在jpa持久性xml文件中自动创建表?

我正在使用eclipse IDE.我也尝试了两个.但是失败..当我在我的mysql数据库中手动创建表时,我的完整程序运行良好...我想要创建表自动关于实体类.

<property name="hibernate.hbm2ddl.auto" value="create"/>

<property name="hibernate.hbm2ddl.auto">update</property>
Run Code Online (Sandbox Code Playgroud)

这里是我的持久文件:

<?xml version="1.0" encoding="UTF-8"?>
  <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="JpaTest2" transaction-type="RESOURCE_LOCAL">

     <class>com.jpa.Employee</class>

    <properties>

        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hibernate"/>
        <property name="javax.persistence.jdbc.user" value="umar"/>
        <property name="javax.persistence.jdbc.password" value="umar"/>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.format_sql" value="true"/>


    </properties>
</persistence-unit>
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa exception

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

exception ×1

hibernate ×1

java ×1

jpa ×1