Hibernate version: 3.1
I can't make many-to-many mapping where Map's index located in entity table, not in relation table.
This is sample from Chapter 1.3.2. A unidirectional Set-based association (
http://www.hibernate.org/hib_docs/v3/re ... -unidirset)
table EVENTS
*EVENT_ID
EVENT_DATE
TITLE
table PERSON_EVENT
*EVENT_ID
*PERSON_ID
table PERSON
*PERSON_ID
AGE
FIRSTNAME
LASTNAME
Code:
<class name="events.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">
<key column="PERSON_ID"/>
<many-to-many column="EVENT_ID" class="events.Event"/>
</set>
</class>
In my case I can't use Set, I need Map where index (key field for Map) is TITLE field in table EVENTS.
Code:
<class name="events.Person" table="PERSON">
<id name="id" column="PERSON_ID">
<generator class="native"/>
</id>
<property name="age"/>
<property name="firstname"/>
<property name="lastname"/>
<map name="events" table="PERSON_EVENT">
<key column="PERSON_ID"/>
<index column="TITLE" type="com.avetti.simplemerce.HibernateEscapedString"/>
<many-to-many column="EVENT_ID" class="events.Event"/>
</map>
</class>
When I use this mapping I have error. In this case Hibernate search field "TITLE" in the table "PERSON_EVENT", not in the table "EVENTS".
Can anybody help me with mapping (without modification of database structure, i can't make "TITLE" as key field in table PERSON_EVENT)?
Sorry, my English isn't good.
Code: