Hello peltokew, i want to now what you're planning to use to be the keys of the map that you're trying to map, it seens to me that you're mapping something like this
Map<Integer,Pictures> using the id of the pictures as a key of the map, it's that you what you want? if so, i could solve it by removing the
not-null="true" in the gallery side and instead i used the not-null="true" on the picture side. Below are the resulting mapping, good luck.
Regards
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="test">
<!-- Map the Gallery class -->
<class name="Gallery" table="gallery">
<!-- Auto-generate the Gallery ID -->
<id name="gallery_id" column="gallery_id" type="integer">
<generator class="increment" />
</id>
<!-- Title of the gallery -->
<property name="title" column="title" type="string" />
<!-- Description of the gallery -->
<property name="description" column="description" type="string" />
<!-- Date of the gallery -->
<property name="date" column="date" type="string" />
<!-- Map the pictures -->
<map name="pictures">
<key column="gallery_id"/>
<map-key type="integer" column="picture_id"/>
<one-to-many class="Picture" />
</map>
</class>
<!-- Map the Picture class -->
<class name="Picture" table="picture">
<!-- Auto-generate the Gallery ID -->
<id name="picture_id" column="picture_id" type="integer">
<generator class="increment" />
</id>
<!-- Title of the gallery -->
<property name="title" column="title" type="string" />
<!-- Description of the gallery -->
<property name="description" column="description" type="string" />
<!-- Date of the gallery -->
<property name="date" column="date" type="string" />
<!-- Width of the picture -->
<property name="width" column="width" type="integer" />
<!-- Height of the picture -->
<property name="height" column="height" type="integer" />
<!-- Binary data representation of the picture -->
<property name="bytes" column="bytes" type="binary" />
<!-- Binary data representation of the thumbnail -->
<property name="thumbnailAsBytes" column="thumbnail"
type="binary" />
<!-- Foreign key which is mapping to the gallery ID that this picture belongs to -->
<many-to-one name="gallery" column="gallery_id" class="Gallery"/>
</class>
</hibernate-mapping>