I have two classes which need to be XML mapped (eventually they will all be modified to Annotations, but currently we need to support the XML mappings).
I have a User object which currently looks like this:
public class User {
private Key key;
private Name name;
}
I need to add in Preferences for some of these users (we have two different types of users which share the same object).
public class Preferences {
private Person person; //The person key acts as our foreign and primary key
private Integer numToShow;
private String defaultScreenToShow;
}
My person XML is as such:
<hibernate-mapping package="com.example.entities">
<id key column="PERSON_ID" /> <!-- Leaving out custom generator -->
<!--
Not sure what the column needs to be here, as
preferences are in own table. Also read it has to
be a faked out many-to-one here as not all users will
have preferences.
-->
<many-to-one name="preferences" not-null="false" />
<component class="com.example.entities.Name">
<property column="first_name" name="first" />
<property column="last_name" name="last" />
</component>
</hibernate-mapping>
My preferences XML file is as such:
<hibernate-mapping package="com.example.entities">
<property column="default_screen" name="defaultScreenToShow" />
<property column="number_search_results" name="numToShow" />
<!-- Not sure what the ID needs to be here -->
</hibernate-mapping>
I'm pretty green with Hibernate in all honesty, but this seems like something which should be pretty easy to map in. I thought I had the mappings done properly, but I get a deserialization exception upon trying to load a person (I've marked the classes as Serializable -- to no avail).