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; } }
时间: 2024-11-10 11:49:06