Umm*_*bal 5 java hibernate jpa exception
我正在使用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)
Nei*_*ton 15
不要使用Hibernate特定选项.JPA 2.1提供
javax.persistence.schema-generation.database.action
Run Code Online (Sandbox Code Playgroud)
可以设置为" 创建 "," 删除 "," 删除并创建 "," 无 ".这样就可以保持代码JPA实现的独立性
小智 0
检查您的实体。你错过了@Table注解吗?该异常清楚地表明该表丢失'hibernate.employee':
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'hibernate.employee' doesn't exist at ...
如果您定义了一个在所有表前面添加hibernate 的命名策略。,然后确保表是在 MySql 中创建的。