I created the mapping files using your table definitions and added the foreign key as mentioned in my previous post. Here are the mapping files:-
TSite.hbm
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>
<class name="TSite" table="T_SITE" >
<id name="siteId" type="big_decimal">
<column name="SITE_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="siteName" type="string">
<column name="SITE_NAME" length="30" not-null="true" />
</property>
<property name="city" type="string">
<column name="CITY" length="30" not-null="true" />
</property>
<property name="state" type="string">
<column name="STATE" length="30" not-null="true" />
</property>
<property name="zip" type="string">
<column name="ZIP" length="30" not-null="true" />
</property>
<property name="plantCode" type="string">
<column name="PLANT_CODE" length="30" />
</property>
<property name="dateCreated" type="date">
<column name="DATE_CREATED" length="7" not-null="true" />
</property>
<property name="dateModified" type="date">
<column name="DATE_MODIFIED" length="7" not-null="true" />
</property>
<set name="TSapsystemAndSites" inverse="true">
<key>
<column name="SITE_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="TSapsystemAndSite" />
</set>
</class>
</hibernate-mapping>
TSapsystemAndSite.hbm.xml
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>
<class name="TSapsystemAndSite" table="T_SAPSYSTEM_AND_SITE">
<composite-id name="id" class="TSapsystemAndSiteId">
<key-property name="siteId" type="big_decimal">
<column name="SITE_ID" precision="22" scale="0" />
</key-property>
<key-property name="sapSystemId" type="big_decimal">
<column name="SAP_SYSTEM_ID" precision="22" scale="0" />
</key-property>
</composite-id>
<many-to-one name="TSapsystem" class="TSapsystem" update="false" insert="false" fetch="select">
<column name="SAP_SYSTEM_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
<many-to-one name="TSite" class="TSite" update="false" insert="false" fetch="select">
<column name="SITE_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
<set name="TSaproleBySapsysAndSites" inverse="true">
<key>
<column name="SITE_ID" precision="22" scale="0" not-null="true" />
<column name="SAP_SYSTEM_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="TSaproleBySapsysAndSite" />
</set>
</class>
</hibernate-mapping>
TSapsystem.hbm.xml
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>
<class name="TSapsystem" table="T_SAPSYSTEM">
<id name="sapSystemId" type="big_decimal">
<column name="SAP_SYSTEM_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="sapSystemName" type="string">
<column name="SAP_SYSTEM_NAME" length="30" not-null="true" />
</property>
<property name="url" type="string">
<column name="URL" length="30" not-null="true" />
</property>
<property name="clientNumber" type="string">
<column name="CLIENT_NUMBER" length="30" />
</property>
<property name="userid" type="string">
<column name="USERID" length="30" not-null="true" />
</property>
<property name="password" type="string">
<column name="PASSWORD" length="30" not-null="true" />
</property>
<property name="iscua" type="java.lang.Character">
<column name="ISCUA" length="1" />
</property>
<property name="dateCreated" type="date">
<column name="DATE_CREATED" length="7" not-null="true" />
</property>
<property name="dateModified" type="date">
<column name="DATE_MODIFIED" length="7" not-null="true" />
</property>
<set name="TSapsystemAndSites" inverse="true">
<key>
<column name="SAP_SYSTEM_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="TSapsystemAndSite" />
</set>
</class>
</hibernate-mapping>
TSaproleBySapsysAndSite.hbm.xml
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>
<class name="TSaproleBySapsysAndSite" table="T_SAPROLE_BY_SAPSYS_AND_SITE">
<id name="sapRoleId" type="big_decimal">
<column name="SAP_ROLE_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<many-to-one name="TSapsystemAndSite" class="TSapsystemAndSite" fetch="select">
<column name="SITE_ID" precision="22" scale="0" not-null="true" />
<column name="SAP_SYSTEM_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
<property name="sapRoleName" type="string">
<column name="SAP_ROLE_NAME" length="30" not-null="true" />
</property>
<property name="sapRoleDescription" type="string">
<column name="SAP_ROLE_DESCRIPTION" length="30" />
</property>
<property name="dateCreated" type="date">
<column name="DATE_CREATED" length="7" not-null="true" />
</property>
<property name="dateModified" type="date">
<column name="DATE_MODIFIED" length="7" not-null="true" />
</property>
</class>
</hibernate-mapping>
PS:- I have renamed some columns and changed timestamp to date, please suit yourself on this one. Also, for all your ids replace the generator with your strategy.
Here I give you the domain objects:-
TSite.java
Code:
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
public class TSite implements java.io.Serializable {
private BigDecimal siteId;
private String siteName;
private String city;
private String state;
private String zip;
private String plantCode;
private Date dateCreated;
private Date dateModified;
private Set TSapsystemAndSites = new HashSet(0);
}
TSapsystemAndSite
Code:
import java.util.HashSet;
import java.util.Set;
public class TSapsystemAndSite implements java.io.Serializable {
private TSapsystemAndSiteId id;
private TSapsystem TSapsystem;
private TSite TSite;
private Set TSaproleBySapsysAndSites = new HashSet(0);
}
TSapsystemAndSiteId
Code:
import java.math.BigDecimal;
public class TSapsystemAndSiteId implements java.io.Serializable {
private BigDecimal siteId;
private BigDecimal sapSystemId;
public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof TSapsystemAndSiteId))
return false;
TSapsystemAndSiteId castOther = (TSapsystemAndSiteId) other;
return ((this.getSiteId() == castOther.getSiteId()) || (this
.getSiteId() != null
&& castOther.getSiteId() != null && this.getSiteId().equals(
castOther.getSiteId())))
&& ((this.getSapSystemId() == castOther.getSapSystemId()) || (this
.getSapSystemId() != null
&& castOther.getSapSystemId() != null && this
.getSapSystemId().equals(castOther.getSapSystemId())));
}
public int hashCode() {
int result = 17;
result = 37 * result
+ (getSiteId() == null ? 0 : this.getSiteId().hashCode());
result = 37
* result
+ (getSapSystemId() == null ? 0 : this.getSapSystemId()
.hashCode());
return result;
}
}
TSapsystem
Code:
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
public class TSapsystem implements java.io.Serializable {
private BigDecimal sapSystemId;
private String sapSystemName;
private String url;
private String clientNumber;
private String userid;
private String password;
private Character iscua;
private Date dateCreated;
private Date dateModified;
private Set TSapsystemAndSites = new HashSet(0);
}
TSaproleBySapsysAndSite
Code:
import java.math.BigDecimal;
import java.util.Date;
public class TSaproleBySapsysAndSite implements java.io.Serializable {
private BigDecimal sapRoleId;
private TSapsystemAndSite TSapsystemAndSite;
private String sapRoleName;
private String sapRoleDescription;
private Date dateCreated;
private Date dateModified;
}
PS: You need to add getter/setters and if required constructors to the above classes to work hand in hand with the mapping files.
Hope all this information gets you away from hitting the brick walls.