LeadedDept类:package com.empiresoft.strs.bean;/**
 * TLeadedDept generated by MyEclipse - Hibernate Tools
 */public class LeadedDept implements java.io.Serializable
{
private static final long serialVersionUID = 7565125946611244846L; // Fields
private LeadedDeptId id; // Constructors /** default constructor */
public LeadedDept()
{
} /** full constructor */
public LeadedDept(LeadedDeptId id)
{
this.id = id;
} // Property accessors public LeadedDeptId getId()
{
return this.id;
} public void setId(LeadedDeptId id)
{
this.id = id;
} @Override
public int hashCode()
{
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((id == null) ? 0 : id.hashCode());
return result;
} @Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final LeadedDept other = (LeadedDept) obj;
if (id == null)
{
if (other.id != null)
return false;
}
else if (!id.equals(other.id))
return false;
return true;
}}
LeadedDeptId类:package com.empiresoft.strs.bean;/**
 * TLeadedDeptId generated by MyEclipse - Hibernate Tools
 */public class LeadedDeptId implements java.io.Serializable
{
private static final long serialVersionUID = 8162438902064507289L;
// Fields
private Integer unitId;
private Integer deptId;
private Integer personId;
private Integer leadDeptId;

// Constructors /** default constructor */
public LeadedDeptId()
{
} /** full constructor */
public LeadedDeptId(Integer unitId, Integer deptId, Integer personId, Integer leadDeptId)
{
this.unitId = unitId;
this.deptId = deptId;
this.personId = personId;
this.leadDeptId = leadDeptId;
} // Property accessors public Integer getUnitId()
{
return unitId;
} public void setUnitId(Integer unitId)
{
this.unitId = unitId;
} public Integer getDeptId()
{
return deptId;
} public void setDeptId(Integer deptId)
{
this.deptId = deptId;
} public Integer getPersonId()
{
return personId;
} public void setPersonId(Integer personId)
{
this.personId = personId;
}

public Integer getLeadDeptId()
{
return this.leadDeptId;
} public void setLeadDeptId(Integer leadDeptId)
{
this.leadDeptId = leadDeptId;
} @Override
public int hashCode()
{
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((deptId == null) ? 0 : deptId.hashCode());
result = PRIME * result + ((leadDeptId == null) ? 0 : leadDeptId.hashCode());
result = PRIME * result + ((personId == null) ? 0 : personId.hashCode());
result = PRIME * result + ((unitId == null) ? 0 : unitId.hashCode());
return result;
} @Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final LeadedDeptId other = (LeadedDeptId) obj;
if (deptId == null)
{
if (other.deptId != null)
return false;
}
else if (!deptId.equals(other.deptId))
return false;
if (leadDeptId == null)
{
if (other.leadDeptId != null)
return false;
}
else if (!leadDeptId.equals(other.leadDeptId))
return false;
if (personId == null)
{
if (other.personId != null)
return false;
}
else if (!personId.equals(other.personId))
return false;
if (unitId == null)
{
if (other.unitId != null)
return false;
}
else if (!unitId.equals(other.unitId))
return false;
return true;
}
}DeptPerson类:package com.empiresoft.strs.bean;import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;/**
 * DeptPerson generated by MyEclipse - Hibernate Tools
 */public class DeptPerson implements java.io.Serializable
{ // Fields private static final long serialVersionUID = -691354392330024350L;
private DeptPersonId id = new DeptPersonId();
private Short headshipId;
private String reportChain;
private Integer positionInDept;
private Date validateTime;
private Date invalidateTime;
private Short invalidateReason;
private Short isValidate;
private Short lvl;
private String personAttr;
private String isPrimary;
private Set<LeadedDept> leadedDepts = new LinkedHashSet<LeadedDept>(0);
// private Set appPersons = new HashSet(0); // Constructors /** default constructor */
public DeptPerson()
{
} /** minimal constructor */
public DeptPerson(DeptPersonId id, String reportChain, Integer positionInDept,
Date validateTime, Short isValidate, Short lvl, String isPrimary)
{
this.id = id;
this.reportChain = reportChain;
this.positionInDept = positionInDept;
this.validateTime = validateTime;
this.isValidate = isValidate;
this.lvl = lvl;
this.isPrimary = isPrimary;
} /** full constructor */
public DeptPerson(DeptPersonId id, Short headshipId, String reportChain,
Integer positionInDept, Date validateTime, Date invalidateTime, Short invalidateReason,
Short isValidate, Short lvl, String personAttr, String isPrimary, Set<LeadedDept> leadedDepts)
{
this.id = id;
this.headshipId = headshipId;
this.reportChain = reportChain;
this.positionInDept = positionInDept;
this.validateTime = validateTime;
this.invalidateTime = invalidateTime;
this.invalidateReason = invalidateReason;
this.isValidate = isValidate;
this.lvl = lvl;
this.personAttr = personAttr;
this.isPrimary = isPrimary;
this.leadedDepts = leadedDepts;
// this.appPersons = appPersons;
} // Property accessors public DeptPersonId getId()
{
return this.id;
} public void setId(DeptPersonId id)
{
this.id = id;
} public Short getHeadshipId()
{
return this.headshipId;
} public void setHeadshipId(Short headshipId)
{
this.headshipId = headshipId;
} public String getReportChain()
{
return this.reportChain;
} public void setReportChain(String reportChain)
{
this.reportChain = reportChain;
} public Integer getPositionInDept()
{
return this.positionInDept;
} public void setPositionInDept(Integer positionInDept)
{
this.positionInDept = positionInDept;
} public Date getValidateTime()
{
return this.validateTime;
} public void setValidateTime(Date validateTime)
{
this.validateTime = validateTime;
} public Date getInvalidateTime()
{
return this.invalidateTime;
} public void setInvalidateTime(Date invalidateTime)
{
this.invalidateTime = invalidateTime;
} public Short getInvalidateReason()
{
return this.invalidateReason;
} public void setInvalidateReason(Short invalidateReason)
{
this.invalidateReason = invalidateReason;
} public Short getIsValidate()
{
return this.isValidate;
} public void setIsValidate(Short isValidate)
{
this.isValidate = isValidate;
} public Short getLvl()
{
return this.lvl;
} public void setLvl(Short lvl)
{
this.lvl = lvl;
} public String getPersonAttr()
{
return this.personAttr;
} public void setPersonAttr(String personAttr)
{
this.personAttr = personAttr;
} public String getIsPrimary()
{
return this.isPrimary;
} public void setIsPrimary(String isPrimary)
{
this.isPrimary = isPrimary;
} public Set<LeadedDept> getLeadedDepts()
{
return this.leadedDepts;
} public void setLeadedDepts(Set<LeadedDept> leadedDepts)
{
this.leadedDepts = leadedDepts;
}// public Set getAppPersons()
// {
// return this.appPersons;
// }
//
// public void setAppPersons(Set appPersons)
// {
// this.appPersons = appPersons;
// } @Override
public int hashCode()
{
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((id == null) ? 0 : id.hashCode());
return result;
} @Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final DeptPerson other = (DeptPerson) obj;
if (id == null)
{
if (other.id != null)
return false;
}
else if (!id.equals(other.id))
return false;
return true;
}}

解决方案 »

  1.   

    TleadeDept.hbm.xml:<?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="com.empiresoft.strs.bean.LeadedDept" table="T_LEADED_DEPT" >
        
                <composite-id name="id" class="com.empiresoft.strs.bean.LeadedDeptId">
             <!--  
                <key-many-to-one name="deptPerson" class="com.empiresoft.strs.bean.DeptPerson" lazy="false">
                    <column name="UNIT_ID"  />
                    <column name="DEPT_ID"  />
                    <column name="PERSON_ID"  />
                </key-many-to-one>
              --> 
                <key-property name="unitId" type="java.lang.Integer">
                    <column name="UNIT_ID" />
                </key-property>
                <key-property name="deptId" type="java.lang.Integer">
                    <column name="DEPT_ID" />
                </key-property>
                <key-property name="personId" type="java.lang.Integer">
                    <column name="PERSON_ID" />
                </key-property>
                <key-property name="leadDeptId" type="java.lang.Integer">
                 <column name="LEAD_DEPT_ID" />
                </key-property>
            </composite-id>
            <set name="DeptPerson" inverse="true" lazy="false">
             <key>
                    <column name="UNIT_ID" not-null="true" />
                    <column name="PERSON_ID" not-null="true" />
                    <column name="DEPT_ID" not-null="true" />
                    <column name="LEAD_DEPT_ID" not-null="true" />
                </key>
                <one-to-many class="com.empiresoft.strs.bean.DeptPerson"/>
                
            </set>
        </class>
    </hibernate-mapping>TDeptPerson.hbm.xml:<?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="com.empiresoft.strs.bean.DeptPerson" table="T_DEPT_PERSON" >
            <composite-id name="id" class="com.empiresoft.strs.bean.DeptPersonId">
                <key-many-to-one name="unitPerson" class="com.empiresoft.strs.bean.UnitPerson" lazy="false">
                    <column name="UNIT_ID" />
                    <column name="PERSON_ID" />
                </key-many-to-one>
                <key-property name="deptId" type="java.lang.Integer">
                    <column name="DEPT_ID" />
                </key-property>
            </composite-id>
            <property name="headshipId" type="java.lang.Short">
                <column name="HEADSHIP_ID" />
            </property>
            <property name="reportChain" type="java.lang.String">
                <column name="REPORT_CHAIN" length="60" not-null="true" />
            </property>
            <property name="positionInDept" type="java.lang.Integer">
                <column name="POSITION_IN_DEPT" not-null="true" />
            </property>
            <property name="validateTime" type="java.util.Date">
                <column name="VALIDATE_TIME" length="23" not-null="true" />
            </property>
            <property name="invalidateTime" type="java.util.Date">
                <column name="INVALIDATE_TIME" length="23" />
            </property>
            <property name="invalidateReason" type="java.lang.Short">
                <column name="INVALIDATE_REASON" />
            </property>
            <property name="isValidate" type="java.lang.Short">
                <column name="IS_VALIDATE" not-null="true" />
            </property>
            <property name="lvl" type="java.lang.Short">
                <column name="LVL" not-null="true" />
            </property>
            <property name="personAttr" type="java.lang.String">
                <column name="PERSON_ATTR" length="1" />
            </property>
            <property name="isPrimary" type="java.lang.String">
                <column name="IS_PRIMARY" length="1" not-null="true" />
            </property>
             
            <set name="leadedDepts" inverse="true" lazy="false" >
                <key>
                    <column name="UNIT_ID" not-null="true" />
                    <column name="PERSON_ID" not-null="true" />
                    <column name="DEPT_ID" not-null="true" />
                    <column name="LEAD_DEPT_ID" not-null="true" />
                    
                </key>
                <one-to-many class="com.empiresoft.strs.bean.LeadedDept" />
            </set>    
        
             
        </class>
    </hibernate-mapping>麻烦大家给我看看 这2个hbm.xml文件到底要怎么配。。谢谢