You didn't misunderstand. I mis-stated the problem. And there shouldn't be anything difficult. I'm just not getting it. :(
The issue was that I can't retrieve the dependent associate objects, and I was wondering if I was forced to place a one-to-many on the primary object mappings and a many-to-one on the subordinate. I haven't seen anything stated explicitly like that, but all the documentation is starting to swim together before my eyes. :)
As an example, of which there are many like it, I provide the mapping for Catalog. Catalog has a field "help" that points to a primary key value in Help (helpID) that I wish to use to associate Help values with Catalogs.
Catalog mapping has a many to one
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.sbf.hibertest.Catalog" table="catalog" dynamic-update="false" dynamic-insert="false" >
<id name="id" column="ID" type="java.lang.Long" length="10" unsaved-value="null" ><generator class="native"> </generator></id>
<property name="basic_price" type="java.math.BigDecimal" update="true" insert="true" column="basic_price" not-null="false" unique="false" />
<property name="dateEnd" type="java.util.Date" update="true" insert="true" column="DateEnd" not-null="false" unique="false" />
<property name="sku" type="long" update="true" insert="true" column="Sku" not-null="false" unique="false" />
<property name="dateStart" type="java.util.Date" update="true" insert="true" column="DateStart" not-null="false" unique="false" />
<many-to-one name="help" class="com.sbf.hibertest.Help" cascade="none" outer-join="auto" update="true" insert="true" column="help" />
</class>
</hibernate-mapping>
and accessors/mutators for Help in Catalog.java
Code:
public Help getHelp() {
return help;
}
public void setHelp(Help help) {
this.help = help;
}
Help is mapped as
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.sbf.hibertest.Help" table="help" dynamic-update="false" dynamic-insert="false" >
<id name="helpID" column="helpID" type="java.lang.Long" length="10" unsaved-value="null" ><generator class="native"> </generator></id>
<property name="helpDescr" type="java.lang.String" update="true" insert="true" column="helpDescr" not-null="false" unique="false" />
<property name="helpLongDescr" type="java.lang.String" update="true" insert="true" column="helpLongDescr" not-null="false" unique="false" />
</class>
</hibernate-mapping>
The Help file has no mapping of one-to-many. This is where I'm confused. There's a ton of documentation re: Collections mapping and the associated one-to-many, but I can't seem to generate a query that doesn't give me a "Can't deserialize a serializable property" error on this simple many to one association.
Could I get some assistance on what a query string that would retreive all of Catalog and its associated help would be like? I know this is easy and I'm just being obtuse, but I've been trying on and off for a few days. Much of that was spent configuring ant, eclipse, and Xdoclet to work and produce the mappings, etc that I'm interested in, but I've spent a bit of time with this query and still can't get it right.
Currently, I'm using the following:
Code:
select cat from Catalog cat, Help help left outer join cat.help as help
I assume that I am failing on the join, which I assume produces the "Can't deserialize blah" exception.
Or am I completely missing the boat.