Blog信息 |
blog名称: 日志总数:1304 评论数量:2242 留言数量:5 访问次数:7594509 建立时间:2006年5月29日 |

| |
[Hibernate]Hibernate的视图功能 软件技术, 电脑与网络
lhwork 发表于 2006/6/15 11:25:42 |
Hibernate3增加了视图功能1. 定义hbm
500)this.width=500'> <class name="Customer" table="customer">500)this.width=500'> 500)this.width=500'> <id name="id" unsaved-value="0" column="id">500)this.width=500'> <generator class="hilo"/>500)this.width=500'> </id>500)this.width=500'> 500)this.width=500'> <property name="name" not-null="true"/>500)this.width=500'> 500)this.width=500'> </class>500)this.width=500'> 500)this.width=500'> <class name="Supplier" table="supplier">500)this.width=500'> 500)this.width=500'> <id name="id" unsaved-value="0" column="id">500)this.width=500'> <generator class="hilo"/>500)this.width=500'> </id>500)this.width=500'> <property name="name" not-null="true"/>500)this.width=500'> 500)this.width=500'> </class>500)this.width=500'> 500)this.width=500'> <class name="All" mutable="false">500)this.width=500'> 500)this.width=500'> <subselect>500)this.width=500'> select id, name from customer500)this.width=500'> union 500)this.width=500'> select id, name from supplier500)this.width=500'> </subselect>500)this.width=500'> 500)this.width=500'> <synchronize table="customer"/>500)this.width=500'> <synchronize table="supplier"/>500)this.width=500'> 500)this.width=500'> <id name="id" unsaved-value="0" column="id">500)this.width=500'> <generator class="hilo"/>500)this.width=500'> </id>500)this.width=500'> 500)this.width=500'> <property name="name"/>500)this.width=500'> 500)this.width=500'> </class>2. 定义POJO
500)this.width=500'>500)this.width=500'>pulic class Customer 500)this.width=500'>{500)this.width=500'> public Integer id;500)this.width=500'> public String name;500)this.width=500'>}500)this.width=500'>500)this.width=500'>500)this.width=500'>pulic class Supplier 500)this.width=500'>{500)this.width=500'> public Integer id;500)this.width=500'> public String name;500)this.width=500'>}500)this.width=500'>500)this.width=500'>500)this.width=500'>pulic class All 500)this.width=500'>{500)this.width=500'> public Integer id;500)this.width=500'> public String name;500)this.width=500'>}3. 查询
500)this.width=500'>List all = session.createQuery("from All").list(); |
|
|