Hibernate3视图功能

Hibernate3增加了视图功能

1. 定义hbm
 
  1. <class name="Customer" table="customer">          
  2.         <id name="id" unsaved-value="0" column="id">  
  3.             <generator class="hilo"/>  
  4.         </id>          
  5.         <property name="name"  not-null="true"/>          
  6.     </class>  
  7.       
  8.     <class name="Supplier" table="supplier">          
  9.         <id name="id" unsaved-value="0" column="id">  
  10.             <generator class="hilo"/>  
  11.         </id>  
  12.         <property name="name" not-null="true"/>              
  13.     </class>  
  14.       
  15.     <class name="All" mutable="false">      
  16.         <subselect>  
  17.             select id, name from customer  
  18.             union   
  19.             select id, name from supplier  
  20.         </subselect>  
  21.           
  22.         <synchronize table="customer"/>  
  23.         <synchronize table="supplier"/>  
  24.           
  25.         <id name="id" unsaved-value="0" column="id">  
  26.             <generator class="hilo"/>  
  27.         </id>          
  28.         <property name="name"/>          
  29.     </class>  
2. 定义POJO
 
  1. pulic class Customer {  
  2.     public Integer id;  
  3.     public String name;  
  4. }  
  5.   
  6. pulic class Supplier {  
  7.     public Integer id;  
  8.     public String name;  
  9. }  
  10.   
  11. pulic class All {  
  12.     public Integer id;  
  13.     public String name;  
  14. }  
3. 查询
 
  1. List all = session.createQuery("from All").list();  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值