<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.url">jdbc:mysql://localhost/ones</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">88888888</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.show_sql">true</property> <mapping resource="com/bjsxt/hibernate/User.hbm.xml"/> </session-factory> </hibernate-configuration>
package ones;
public class User {
private String id;
private String name;
private String password;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="org.hibernate.auction">
<class name="User" table="AuctionUser" lazy="true">
<comment>Users may bid for or sell auction items.</comment>
<id name="id">
<generator class="native"/>
</id>
<natural-id mutable="true">
<property name="userName"
length="10"/>
</natural-id>
<property name="password"
not-null="true"
length="15"
column="`password`"/>
<property name="email"/>
<component name="name">
<property name="firstName"
length="50"
not-null="true"/>
<property name="initial"
column="`initial`"/>
<property name="lastName"
length="50"
not-null="true"/>
</component>
<bag name="bids"
inverse="true"
cascade="save-update,lock">
<key column="bidder"/>
<one-to-many class="Bid"/>
</bag>
<bag name="auctions"
inverse="true"
cascade="save-update,lock">
<key column="seller"/>
<one-to-many class="AuctionItem"/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="ones"> <class name="User" > <id name="id"> <generator class="uuid"/> </id> <property name="name"></property> <property name="password"></property> </class> </hibernate-mapping>
package ones;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class ExportDB {
public static void main(String[] args) {
//读取文件的配置
Configuration cfg = new Configuration().configure();
SchemaExport export = new SchemaExport(cfg);
export.create(ture, ture);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有