composite-id(二)

 

第二,将composite-id导入 class SkillTable中设为主键<o:p></o:p>

<o:p> </o:p>

/**<o:p></o:p>

 * @hibernate.id class="com.sunnyever.model.SkillTableKey"<o:p></o:p>

 * <o:p></o:p>

 */<o:p></o:p>

<o:p> </o:p>

    public SkillTableKey getKey() {<o:p></o:p>

       return key;<o:p></o:p>

    }<o:p></o:p>

<o:p> </o:p>

下面为class SkillTable<o:p></o:p>

**<o:p></o:p>

 * @struts.form include-all="true" extends="BaseForm"<o:p></o:p>

 * @hibernate.class<o:p></o:p>

 *         table="SKILL_TABLE"<o:p></o:p>

 *     <o:p></o:p>

 */<o:p></o:p>

<o:p> </o:p>

public class SkillTable extends com.sunnyever.model.BaseObject implements java.io.Serializable {<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

    // Fields    <o:p></o:p>

    private SkillTableKey  key;<o:p></o:p>

  <o:p></o:p>

    private String skill;<o:p></o:p>

    private String level1;<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

    // Constructors<o:p></o:p>

<o:p> </o:p>

    /** default constructor */<o:p></o:p>

    public SkillTable() {<o:p></o:p>

    }<o:p></o:p>

<o:p> </o:p>

    <o:p></o:p>

    /** full constructor */<o:p></o:p>

    public SkillTable(SkillTableKey  key, String skill, String level1) {<o:p></o:p>

        this.key=key;<o:p></o:p>

        this.skill = skill;<o:p></o:p>

        this.level1 = level1;<o:p></o:p>

    }<o:p></o:p>

    <o:p></o:p>

/**<o:p></o:p>

 * @hibernate.id class="com.sunnyever.model.SkillTableKey"<o:p></o:p>

 * <o:p></o:p>

 */<o:p></o:p>

<o:p> </o:p>

    public SkillTableKey getKey() {<o:p></o:p>

       return key;<o:p></o:p>

    }<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

    public void setKey(SkillTableKey key) {<o:p></o:p>

       this.key = key;<o:p></o:p>

    }<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

    /**  <o:p></o:p>

     *         <o:p></o:p>

     *                @hibernate.property<o:p></o:p>

     *                 column="SKILL"<o:p></o:p>

     *                 type="java.lang.string"<o:p></o:p>

     */<o:p></o:p>

<o:p> </o:p>

    public String getSkill() {<o:p></o:p>

        return this.skill;<o:p></o:p>

    }<o:p></o:p>

    <o:p></o:p>

    public void setSkill(String skill) {<o:p></o:p>

        this.skill = skill;<o:p></o:p>

    }<o:p></o:p>

    /**   <o:p></o:p>

     *         <o:p></o:p>

     *                @hibernate.property<o:p></o:p>

     *                 column="LEVEL1"<o:p></o:p>

     *             type="java.lang.string"<o:p></o:p>

     */<o:p></o:p>

<o:p> </o:p>

    public String getLevel1() {<o:p></o:p>

        return this.level1;<o:p></o:p>

    }<o:p></o:p>

    <o:p></o:p>

    public void setLevel1(String level1) {<o:p></o:p>

        this.level1 = level1;<o:p></o:p>

    }<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

    @Override<o:p></o:p>

    public int hashCode() {<o:p></o:p>

       final int PRIME = 31;<o:p></o:p>

       int result = 1;<o:p></o:p>

       result = PRIME * result + ((key == null) ? 0 : key.hashCode());<o:p></o:p>

       result = PRIME * result + ((level1 == null) ? 0 : level1.hashCode());<o:p></o:p>

       result = PRIME * result + ((skill == null) ? 0 : skill.hashCode());<o:p></o:p>

       return result;<o:p></o:p>

    }<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

    @Override<o:p></o:p>

    public

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值