## \u6570\u636e\u5e93\u94fe\u63a5
hibernate.dialect org.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl
hibernate.connection.username scott
hibernate.connection.password tiger
<!DOCTYPE hibernate-mapping SYSTEM "[url]http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd[/url]" >
<hibernate-mapping>
<class name="org.apple.hibernate.User" table="usertest">
<!--hibernate为我们生成主键id-->
<id name = "id" unsaved-value = "null">
<generator class="uuid.hex"/>
</id>
<!--默认把类的变量映射为相同名字的表列,当然我们可以修改其映射方式-->
<property name="name"/>
<property name="password"/>
</class>
</hibernate-mapping>
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
private static SessionFactory sessions;
Configuration conf= new Configuration()
.addClass(User.class);
SchemaExport dbExport=new SchemaExport(conf);
dbExport.create(true, true);
sessions = conf.buildSessionFactory();
//start......
Session s = sessions.openSession();
Transaction t = s.beginTransaction();
System.out.println("start create table ");
User p1=new User();
p1.setName("刘俊杰");
p1.setPassword("12345689�㶫����");
System.out.println("insert suceess");
s.save(p1);
System.out.println("save suceess");
s.close();
}