org.hibernate.invalidmappingexception:无法从资源hibernate.hbm.xml解析Map文档为什么我会得到它?

xytpbqjk  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(256)

在尝试将文本文件写入数据库时,出现以下异常:

org.hibernate.InvalidMappingException: Could not parse mapping document 
from resource hibernate.hbm.xml

只要我点击 html 提交按钮:

<form method="post" enctype="multipart/form-data" action="FileHandler">
        <input type="file" name="file" /> <br />
        <input type="submit" value="submit" />
</form>

我不知道为什么我会得到它。下面是hibernateMap文件:

<hibernate-mapping>
      <class name="pojo.File" table="b_files"/>
        <id name="serial_number">
      <generator class="increment" />
        </id>
        <property name="file" />
    </hibernate-mapping>

下面是课程里面的内容 pojo package (Map类):

package pojo;

public class File {
    private byte file[] = new byte[5120];
    private int serial_number;

    public int getSerial_number() {
        return serial_number;
    }

    public void setSerial_number(int serial_number) {
        this.serial_number = serial_number;
    }

    public byte[] getFile() {
        return file;
    }

    public void setFile(byte[] file) {
        this.file = file;
    }

}

我使用this命令创建了一个名为 b_files :

create table b_files(files_uploaded mediumblob, serial_number integer);

注意:我猜,Map文件中名为“file”的属性有问题。这样可以吗?因为在我的netbeanside中没有得到“file”作为提示。所以我想这可能就是问题所在。

laik7k3q

laik7k3q1#

你在错误的地方下课。 id 以及 property 应该在 </class> ,不关闭在其原始行中有快捷方式的类。

相关问题