I have two mapping files, and corresponding Java classes.
Mapping files are as follows..
File 1
=====
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="myPackage">
<class name="TCMClaimCenterUserCargo"
table="CC_USER"
mutable="false">
<id name="id"
type="java.lang.Integer"
column="ID"
unsaved-value="null">
<generator class="assigned"/>
</id>
<property name="publicId" type="java.lang.String" column="PUBLICID" />
<property name="officeCode" type="java.lang.String" column="LMOFFICECODE" />
</class>
</hibernate-mapping>
==========
Mapping File 2
==========
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="myPackage">
<class name="TCMClaimCenterGroupUserCargo"
table="CC_GROUPUSER"
mutable="false">
<composite-id>
<key-property name="groupID" type="java.lang.Integer" column="GROUPID" />
<key-property name="userID" type="java.lang.Integer" column="USERID" />
</composite-id>
<property name="textField1" type="java.lang.String" column="TEXTFIELD1" />
<property name="textField2" type="java.lang.String" column="TEXTFIELD2" />
<property name="textField3" type="java.lang.String" column="TEXTFIELD3" />
<property name="manager" type="java.lang.String" column="MANAGER" />
<property name="member" type="java.lang.String" column="MEMBER" />
<property name="loadFactorType" type="java.lang.Integer" column="LOADFACTORTYPE" />
<property name="loadHistoryID" type="java.lang.Integer" column="LOADHISTORYID" />
<property name="loadFactor" type="java.lang.Integer" column="LOADFACTOR" />
<!--
<property name="id" type="java.lang.Integer" column="USERID" />
<property name="groupID" type="java.lang.Integer" column="GROUPID" />
-->
</class>
</hibernate-mapping>
I need these two files to map to each other so that an inner join is performed. I've tried a few options but I'm not having any luck. The SQL I'm trying to achieve is below...
Select DISTINCT ('0'||(Substr(gr.TEXTFIELD1,1,3))) as OFFICECODE
From DB.CC_GROUPUSER gr
Inner Join DB.CC_USER u on gr.USERID = u.ID
WHERE gr.TEXTFIELD1 IS NOT NULL
Can anyone tell me what I should be doing to get this? I'm totally confused. Both Java files corresponding to the XML have all properties specified in the XML defined in the Java also, along with appropriate getter / setter methods.
Any help is greatly appreciated!!!!