刘小文 2014-07-30
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<classname="net.gehua.weixin.model.sendMsg.SendMsg"table="t_send_msg"lazy="false">
<idname="id"type="java.lang.Long">
<generatorclass="increment"/>
</id>
<!--鉴别器字段,必须放在id后面.子类中要添加discriminator-value="?",给鉴别器字段赋值-->
<discriminatorcolumn="type"type="string"/><!--这里的string类型是Hibernate的类型,全小写-->
<propertyname="msgType"/>
<propertyname="createTime"column="create_time"/>
<propertyname="updateTime"column="update_time"/>
<subclassname="net.gehua.weixin.model.sendMsg.SendImageMsg"discriminator-value="SendImageMsg">
<propertyname="mediaId"/>
</subclass>
<subclassname="net.gehua.weixin.model.sendMsg.SendTextMsg"discriminator-value="SendTextMsg">
<propertyname="content"/>
</subclass>
</class>
</hibernate-mapping>
class属性一定要添加lazy="false"get方法才支持多态查询