在下面的場景中,多對多關聯,什麼是適當的查詢傳遞給getHibernateTemplate()。find()方法,以獲得有參與者的事件的事件(和人員)列表?getHibernateTemplate()。find()over many-to-many association
_____________ __________________
| | | | _____________
| EVENTS | | PERSON_EVENT | | |
|_____________| |__________________| | PERSON |
| | | | |_____________|
| *EVENT_ID | <--> | *EVENT_ID | | |
| EVENT_DATE | | *PERSON_ID | <--> | *PERSON_ID |
| TITLE | |__________________| | AGE |
|_____________| | FIRSTNAME |
| LASTNAME |
|_____________|
<class name="Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
<set name="participants" table="PERSON_EVENT">
<key column="EVENT_ID"/>
<many-to-many column="PERSON_ID" class="Person"/>
</set>
</class>
<class name="Person" table="PERSON">
<id name="id" column="PERSON_ID">
<generator class="native"/>
</id>
<property name="age"/>
<property name="firstname"/>
<property name="lastname"/>
<set name="events" table="PERSON_EVENT" inverse="true">
<key column="PERSON_ID"/>
<many-to-many column="EVENT_ID" class="Event"/>
</set>
</class>
多次試圖像這樣的失敗,但以下情況除外:
getHibernateTemplate().find("from Event event where event.participants != null");
org.springframework.dao.InvalidDataAccessResourceUsageException等等等等 嵌套的例外是org.hibernate.exception.SQLGrammarException:無法執行查詢 等等
謝謝!