hibernate hbm.xml文件

配置数据库连接1>
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=yes)(FAILOVER=on)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.1.6.1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVICE_NAME=RACDB)(FAILOVER_MODE=(TYPE=select)(DELAY=5)(METHOD=basic))))</property>
<!--<property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:MASTER</property>-->
<property name="connection.username">usera</property>
<property name="connection.password">pwda</property>
<property name="connection.pool_size">5</property>
<property name="show_sql">true</property>

<mapping resource="com/entity/QueryLog.hbm.xml"/>
<mapping resource="com/entity/Operator.hbm.xml"/>
</session-factory>
</hibernate-configuration>

配置数据库连接2>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@192.168.0.3:1521:ORA92</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="connection.username">nnnnnnnn</property>
<property name="connection.password">xxxxxxx</property>
<property name="statement_cache.size">10</property>
<property name="show_sql">false</property>
<property name="connection.pool_size">5</property>
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
<property name="use_outer_join">true</property>

<mapping resource="com/Dictionary.hbm.xml"/>

</session-factory>
配置数据库连接3>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/datasourcename</property>或
<property name="connection.datasource">XX_DataSource</property>(apusic下)或
<property name="connection.datasource">java:comp/env/XX_DataSource</property>(tomcate下)
<property name="show_sql">false</property>
<property name="connection.pool_size">5</property>
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
<property name="use_outer_join">true</property>

<mapping resource="com/Dictionary.hbm.xml"/>

</session-factory>


实体间的关联关系
Order与Customer是m:1的关系
Order.hbm.xml
Order和一个Customer类型的成员变量
<many-to-one
name="customer"
column="customer_id"
class="Customer"
not-null="true"
/>
Customer.hbm.xml
Customer有一个orders集合,元素是Order
<set
name="orders"
cascade="delete"
inverse="true" 被维护端
>
<key column="customer_id" />
<one-to-many class="Order" />
</set>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值