The key, as for all collection mappings, is the column in the association table which identifies the map owner.
The index represent the column in the association table to be used as the index or key of the Map.
The element represents the column in the association table to be used as the element or value of the Map for the given index.
Quote:
And if the HashMap is inside an object
The map must be owned by a persistent class, so this question does not really make sense. Maybe I misunderstood what your asking?
As an example, say you have a class named Book and part of the Book class is a localized assoication to the contents of the book. The class looks something like:
Code:
public class Book
{
private Long id;
java.util.Map localizedContent = new java.util.HashMap();
...
// Getters and setters...
}
And you want to map this content to an association table:
BOOK_CONTENT
----------------------------
BOOK_ID INTEGER
LOCALE VARCHAR(5)
CONTENT_LOCATION VARCHAR(4000)
That would look like:
Code:
<class name="Book" table="... >
...
<map name="localizedContent" table="book_content">
<key column="book_id"/>
<index column="locale"/>
<element column="content_location"/>
</map>
</class>
After loading an instance of Book, the getLocalizedContent() method would return a Map of the book's content keyed by the locale for that particular content.