配置文件如下:
<?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.maystar.model.Teacher"
        table="teacher"
    >        <id
            name="teacherID"
            column="teacherID"
            type="int"
            unsaved-value="null"
        >
            <generator class="identity">
              <!--  
                  To add non XDoclet generator parameters, create a file named 
                  hibernate-generator-params-Teacher.xml 
                  containing the additional parameters and place it in your merge dir. 
              --> 
            </generator>
        </id>        <property
            name="paperID"
            type="int"
            update="true"
            insert="true"
            column="paperID"
        />        <property
            name="course"
            type="java.lang.String"
            update="true"
            insert="true"
            column="course"
        />        <property
            name="grade"
            type="java.lang.String"
            update="true"
            insert="true"
            column="grade"
        />        <property
            name="name"
            type="java.lang.String"
            update="true"
            insert="true"
            column="name"
        />        <property
            name="notes"
            type="java.lang.String"
            update="true"
            insert="true"
            column="notes"
        />        <property
            name="operateCustom"
            type="java.lang.String"
            update="true"
            insert="true"
            column="operateCustom"
        />        <property
            name="passwd"
            type="java.lang.String"
            update="true"
            insert="true"
            column="passwd"
        />        <property
            name="permitItem"
            type="java.lang.String"
            update="true"
            insert="true"
            column="permitItem"
        />        <property
            name="permitPaper"
            type="java.lang.String"
            update="true"
            insert="true"
            column="permitPaper"
        />        <property
            name="teachClass"
            type="java.lang.String"
            update="true"
            insert="true"
            column="teachClass"
        />        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Teacher.xml
            containing the additional properties and place it in your merge dir.
        -->    </class></hibernate-mapping>

解决方案 »

  1.   

    类文件如下:
    package com.maystar.model;/**
     * @hibernate.class table="teacher"
     * @author aut
     *
     */
    public class Teacher {
    private int teacherID;
    private int paperID;    
    private String passwd;
    private String permitItem;
    private String permitPaper;
    private String name;  
    private String course;
    private String grade;        
    private String teachClass;        
    private String operateCustom;
    private String notes;

    /**
     * @hibernate.id generator-class="native" unsaved-value="null"
     * @return Returns the teacherID.
     */
    public int getTeacherID() {
    return teacherID;
    }
    /**
     * @param teacherID The teacherID to set.
     */
    public void setTeacherID(int teacherID) {
    this.teacherID = teacherID;
    }
    /**
     * @hibernate.property
     * @return Returns the paperID.
     */
    public int getPaperID() {
    return paperID;
    }
    /**
     * @param paperID The paperID to set.
     */
    public void setPaperID(int paperID) {
    this.paperID = paperID;
    }
    /**
     * @hibernate.property
     * @return Returns the course.
     */
    public String getCourse() {
    return course;
    }
    /**
     * @param course The course to set.
     */
    public void setCourse(String course) {
    this.course = course;
    }
    /**
     * @hibernate.property
     * @return Returns the grade.
     */
    public String getGrade() {
    return grade;
    }
    /**
     * @param grade The grade to set.
     */
    public void setGrade(String grade) {
    this.grade = grade;
    }
    /**
     * @hibernate.property
     * @return Returns the name.
     */
    public String getName() {
    return name;
    }
    /**
     * @param name The name to set.
     */
    public void setName(String name) {
    this.name = name;
    }
    /**
     * @hibernate.property
     * @return Returns the notes.
     */
    public String getNotes() {
    return notes;
    }
    /**
     * @param notes The notes to set.
     */
    public void setNotes(String notes) {
    this.notes = notes;
    }
    /**
     * @hibernate.property
     * @return Returns the operateCustom.
     */
    public String getOperateCustom() {
    return operateCustom;
    }
    /**
     * @param operateCustom The operateCustom to set.
     */
    public void setOperateCustom(String operateCustom) {
    this.operateCustom = operateCustom;
    }

    /**
     * @hibernate.property
     * @return Returns the passwd.
     */
    public String getPasswd() {
    return passwd;
    }
    /**
     * @param passwd The passwd to set.
     */
    public void setPasswd(String passwd) {
    this.passwd = passwd;
    }
    /**
     * @hibernate.property
     * @return Returns the permitItem.
     */
    public String getPermitItem() {
    return permitItem;
    }
    /**
     * @param permitItem The permitItem to set.
     */
    public void setPermitItem(String permitItem) {
    this.permitItem = permitItem;
    }
    /**
     * @hibernate.property
     * @return Returns the permitPaper.
     */
    public String getPermitPaper() {
    return permitPaper;
    }
    /**
     * @param permitPaper The permitPaper to set.
     */
    public void setPermitPaper(String permitPaper) {
    this.permitPaper = permitPaper;
    }
    /**
     * @hibernate.property
     * @return Returns the teachClass.
     */
    public String getTeachClass() {
    return teachClass;
    }
    /**
     * @param teachClass The teachClass to set.
     */
    public void setTeachClass(String teachClass) {
    this.teachClass = teachClass;
    }


    }
      

  2.   

    在2,也就是配置文件中写insert语句后面加";"(分号),仍然报相同的错,不过数据库中写进记录了。刚才我的配置文件没有分号.
    问题是怎样让它不报错啊
    呵呵
      

  3.   

    应该说是Hibernate对Access没有什么支持,因为dialect中就没有Access支持,我用的是ms sqlserver.故而会出现1种select scope_identity(),然而直接写insert语句也有点问题,那就是Access好像对有"自动编号"列的表执行完insert语句后还要执行点什么,还有就是Hibernate配置中只能执行一条语句.