码迷,mamicode.com
首页 > 其他好文 > 详细

继承映射关系 subclass的查询

时间:2015-08-17 18:48:55      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

 Person大类的映射文件配置


1
<hibernate-mapping package="com.zh.hibernate.subclass"> 2 3 <class name="Person" table="PERSONS" discriminator-value="PERSONS"> 4 5 <id name="id" type="java.lang.Integer"> 6 <column name="ID" /> 7 <generator class="native" /> 8 </id> 9 10 <discriminator column="TYPE" type="string"></discriminator> 11 12 <property name="name" type="java.lang.String"> 13 <column name="NAME" /> 14 </property> 15 16 <property name="age" type="java.lang.String"> 17 <column name="AGE" /> 18 </property> 19 20 <subclass name="Student" discriminator-value="STUDENT"> 21 <property name="school" type="string" column="SCHOOL"></property> 22 </subclass> 23 24 </class> 25 26 </hibernate-mapping>

 

查询语句的区别

Hibernate:
    select
        person0_.ID as ID1_0_0_,
        person0_.NAME as NAME3_0_0_,
        person0_.AGE as AGE4_0_0_,
        person0_.SCHOOL as SCHOOL5_0_0_,
        person0_.TYPE as TYPE2_0_0_
    from
        PERSONS person0_
    where
        person0_.ID=?
11, zzqq
Hibernate:
    select
        student0_.ID as ID1_0_0_,
        student0_.NAME as NAME3_0_0_,
        student0_.AGE as AGE4_0_0_,
        student0_.SCHOOL as SCHOOL5_0_0_
    from
        PERSONS student0_
    where
        student0_.ID=?
        and student0_.TYPE=‘STUDENT‘

 

继承映射关系 subclass的查询

标签:

原文地址:http://www.cnblogs.com/overtime-zhao/p/4737288.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!