【发布时间】:2014-07-04 02:17:01
【问题描述】:
我的项目中有 Hibernate,
但还没有春天。
我想知道是否:
问题一:
persistence.xml中的Hibernate注解和方言属性是否足以让Hibernate生成表?
问题 2: 另外我想,一定有像 Spring 这样的东西来寻找注释并触发一个生成事件并开始一些其他的事情?
编辑:
我的 persistence.xml 文件
<?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="Kutuphane2" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>kutuphaneDS</non-jta-data-source>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/kutuphane"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
<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"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
</properties>
</persistence-unit>
</persistence>
【问题讨论】: