码迷,mamicode.com
首页 > 其他好文 > 详细

SSH实例(4)

时间:2015-06-07 17:26:11      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:

Clas.hbm.xml文件如下:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="com.school.entity.Clas" table="clas">
        <id name="id" type="java.lang.Integer">
            <column name="ID" precision="22" scale="0" />
            <generator class="identity" />
        </id>
        <property name="name" type="java.lang.String">
            <column name="NAME"  length="50" not-null="true">
                <comment>课程名称</comment>
            </column>
        </property>
        <property name="comment" type="java.lang.String">
            <column name="COMMENT" length="500" not-null="false">
                <comment>课程介绍</comment>
            </column>
        </property>
    </class>
</hibernate-mapping>

Clas.java文件如下:

package com.school.entity;

public class Clas {    

    // 课程id
    private int id;
    // 课程名称
    private String name;
    // 课程介绍
    private String comment;
    
    // 默认构造方法
    public Clas() {
    }
    
    // 包含全部属性的构造方法
    public Clas(int id, String name, String comment) {
        super();
        this.id = id;
        this.name = name;
        this.comment = comment;
    }
    
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getComment() {
        return comment;
    }
    public void setComment(String comment) {
        this.comment = comment;
    }

}

 

SSH实例(4)

标签:

原文地址:http://www.cnblogs.com/mstk/p/4558607.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!