Having trouble mapping a "map" collection:
Table 1:
Code:
CREATE TABLE Messages (
messageId BIGINT IDENTITY NOT NULL)
Table 2:Code:
CREATE TABLE MessageProperties (
messagePropertyId BIGINT IDENTITY NOT NULL,
messageId BIGINT NOT NULL,
messagePropertyName VARCHAR(50) NOT NULL,
messagePropertyValue VARCHAR(4000) NOT NULL)
Mapping:Code:
<map
name="messageProperties"
table="MessageProperties"
lazy="false"
sort="unsorted"
cascade="none"
outer-join="true"
>
<key
column="messageId"
>
</key>
<index
column="messagePropertyName"
type="java.lang.String"
/>
<element
column="messagePropertyValue"
type="java.lang.String"
not-null="false"
unique="false"
/>
</map>
Message class:Code:
public class Message {
private Map messageProperties;
public void setMessageProperties(Map messageProperties){
this.messageProperties = messageProperties;
}
public Map getMessageProperties(){
return messageProperties;
}
}
There is no MessageProperty class, I'm trying to load values from the MessageProperties table directly into a Map object, with the value from the messagePropertyName column becoming the Map entry's
key and the value from the messagePropertyValue column becoming the Map entry's
value.
So after loading a Message object, that definitely has associated properties in the database, the messageProperties Map is null. I'm not sure what the problem is, but I'm having a hard time finding any help in the forum or the documentation. Any help would be greatly appreciated!
Brian