spring 整合的hibernate,有实体类,映射文件,无法生成数据库表
spring中自动生成表的配置:<propertyname="hibernateProperties"><props><propkey="hibernate.dialec...
spring中自动生成表的配置:
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hbm2ddl.auto">create</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- <prop key="current_session_context_class">Thread</prop> -->
</props>
</property>
实体类:
public class Admin implements java.io.Serializable {
// Fields
private Integer id;
private String username;
private String password;
// Constructors
/** default constructor */
public Admin() {
}
/** full constructor */
public Admin(Integer id, String username, String password) {
this.id = id;
this.username = username;
this.password = password;
}
setter、getter;
}
映射文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.bzu.entity.Admin" table="admin">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="native" />
</id>
<property name="username" type="java.lang.String">
<column name="username" length="20" not-null="true" />
</property>
<property name="password" type="java.lang.String">
<column name="password" length="20" not-null="true" />
</property>
</class>
</hibernate-mapping> 展开
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hbm2ddl.auto">create</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- <prop key="current_session_context_class">Thread</prop> -->
</props>
</property>
实体类:
public class Admin implements java.io.Serializable {
// Fields
private Integer id;
private String username;
private String password;
// Constructors
/** default constructor */
public Admin() {
}
/** full constructor */
public Admin(Integer id, String username, String password) {
this.id = id;
this.username = username;
this.password = password;
}
setter、getter;
}
映射文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.bzu.entity.Admin" table="admin">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="native" />
</id>
<property name="username" type="java.lang.String">
<column name="username" length="20" not-null="true" />
</property>
<property name="password" type="java.lang.String">
<column name="password" length="20" not-null="true" />
</property>
</class>
</hibernate-mapping> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询