SHH框架下Hibernater的配置

Hibernate的配置

首先已经通过MyEclipse DataBase Explorer新建一个连接数据库的项目(A)

---MyEclipse---Add Hibernate Capabilities

出现对话框添加 Hibernater Capabilities 连接已建立的数据库项目(A),此时自动创建的Hibernate.cfg.xml放在 src目录的 */util下。完成session-factory的创建。

---MyEclipse DataBase Explorer---A--connected to A--(数据库的用户)---TABLE
选择已经创建的表 点击右键---Hibernate Reverse Engineering--Java src folder//  java package// --bean---Id Generate(Sequence) 逆向生成bean

注意:1)先Add Hibernate Capabilities是因为使用逆向生成功能只能在Hibernate项目下才能实现。
      2)Hibernate.cfg.xml 放在 src folder 的*.util下

代码参考:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
<property name="connection.username">dwj</property>
<property name="connection.url">
jdbc:oracle:thin:@PC-200911181406:1521:dgy
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="myeclipse.connection.profile">ebay</property>
<property name="connection.password">dwj</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="show_sql">true</property>
<mapping resource="daniel/bean/EbaySellgoods.hbm.xml" />
<mapping resource="daniel/bean/EbaySortinfo.hbm.xml" />
<mapping resource="daniel/bean/EbaySysteminfo.hbm.xml" />
<mapping resource="daniel/bean/EbayBuygoods.hbm.xml" />
<mapping resource="daniel/bean/EbaySellmessage.hbm.xml" />
<mapping resource="daniel/bean/EbayUserinfo.hbm.xml" />

</session-factory>

</hibernate-configuration>

猜你喜欢

转载自danielhjd.iteye.com/blog/1039095