我有对象:
PersenInfo : (long id,String name, String lastName,String email)
AnsMsg : (long id,PersenInfo fromPersoninfo,String theMsg)
Person : (PersonInfo personInfo, List<AnsMsg> msgs)
person.hbm 看起来像这样:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated May 4, 2012 2:48:41 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="Entities.Person" table="PERSON">
<id name="id" type="long">
<column name="ID" />
<generator class="increment" />
</id>
<many-to-one name="personInfo" class="Entities.PersonInfo" cascade="all" not-null="false" lazy="false"/>
<property name="_pass" type="java.lang.String" access="field" lazy="false">
<column name="_PASS" />
</property>
<property name="_IsConnect" type="int" access="field" lazy="false">
<column name="_ISCONNECT" />
</property>
<property name="c2dmId" type="java.lang.String" lazy="false">
<column name="C2DMID" />
</property>
<property name="lastSeen" type="long" lazy="false">
<column name="LASTSEEN" />
</property>
<list name="msgList" inverse="false" table="ANSMSG" lazy="false" >
<key column="parent_id" />
<index column="idx" />
<one-to-many class="msg.AnsMsg" />
</list>
</class>
</hibernate-mapping>
现在我尝试获取AnsMsg
fromPerson=6 和AnsMsg
parent_id=3 的所有列表;
我的查询应该是什么样子?(我的意思是这样的:
"from AnsMsg ansMsg where ansMsg.fromPerson.id='6' or ansMsg.parent_id='6'"
当然这个查询不应该工作..)
我的数据看起来很像:
提前致谢。