Hi there,
I'm pretty new to Hibernate and completely stuck. I want to persist the following in MySQL5:
Code:
package mypackage;
public class Job implements Serializable {
...
private static final long serialVersionUID = ...
private long id;
private List<Task> tasks = new ArrayList<Task>();
...
(getters/setters)
...
}
Code:
package mypackage;
public class Task implements Serializable {
...
private static final long serialVersionUID = ...
private long id;
private String taskName;
private Map<String, String> properties = new HashMap<String, String>();
...
(getters/setters)
...
}
The mappings so far:
Code:
...
<hibernate-mapping>
   <class name="mypackage.Job"
      table="transcoder_jobs">
      <id name="id" column="id" type="long" length="11">
         <generator class="increment" />
      </id>
...
<list name="tasks" table="job_tasks">
         <key column="id" />
         <list-index column="sequence" />
         <element type="mypackage.Task" column="task" not-null="true"/>
      </list>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
   <class name="mypackage.Task"
      table="job_tasks">
      <id name="id" column="id" type="long" length="11">
         <generator class="native" />
      </id>
      <property name="taskName" type="string">
         <column name="taskName" not-null="false" />
      </property>
   <property name="properties" type="java.util.HashMap" update="false">
      <column name="properties" not-null="true" />
   </property>
   </class>
</hibernate-mapping>
Basically, it's one object containing a List of other objects which are holding a string/string Map.
The code works so far, i can save objects, but the properties-map (which is a BLOB in the DB) is 0 bytes in size.
But when i try to retrieve an object, I get a
Code:
org.hibernate.type.SerializationException: could not deserialize
What's wrong here? I guess I have to set some kind of relation between objects in the mappings, but I have no idea which one and how.
Or am I completely wrong here?
Any help is _VERY_ highly appreciated, a working example of such a mapping would be just perfect!
Thank you very much for your help!
-- snowcrashed