Query:
1. from invItem c where c.regularDoc is null; ---no rows return, should be a
large number of rows
2. from invItem c where c.regularDoc is not null; --- returned the correct
rows, cast (InvDecalItem) to get the rows.
3. from invItem c left join c.regularDoc doc where doc is null; --- returned
rows, but I got cast exception (I cast the row to (InvDecalItem) as well as
(InvItem) type) when I want to get row information.
4. from invItem c left join c.regularDoc doc where doc is not null; ---
returned rows, the same as 3.
I think of using join, I want to know that how to cast the result rows?
<hibernate-mapping>
<class name="InvItem">
<id name="id" column="id">
<generator class="hilo"/>
</id>
<discriminator column="invType" length="1"/>
<many-to-one name="transferredDetails"/> <!-- FK: Points to
corresponding entry for transferred inventory items -->
<subclass name="InvDecalItem" discriminator-value='D'>
<one-to-one name="regularDoc" property-ref="decalNew"
access="field" /> <!-- nullable: an item maybe not attach to a document -->
</subclass>
</class>
</hibernate-mapping>
</hibernate-mapping>
<class name="AbstractRegularDoc" table="RegularDoc">
<id name="id">
<generator class="hilo"/>
</id>
<many-to-one name="decalNew" index="decalIdx" access="field"
unique="true"/>
</class>
</hibernate-mapping>
public abstract class AbstractRegularDoc{
private InvDecalItem decalNew;
...
public InvDecalItem getDecalNew()
{
return decalNew;
}
public void setDecalNew(InvDecalItem decalNewParam)
{
if (decalNewParam != null)
decalNewParam.setRegularDoc(this);
}
}
public class InvDecalItem extends InvItem
{
private AbstractRegularDoc regularDoc;
public AbstractRegularDoc getRegularDoc()
{
return regularDoc;
}
public void setRegularDoc(AbstractRegularDoc regulardocs)
{
if (this.regularDoc != null)
this.regularDoc.setDecalNew(this);
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel