【问题标题】:org.hibernate.InvalidMappingException: Could not parse mapping document from resource hibernate.hbm.xml. Why am I getting it?org.hibernate.InvalidMappingException:无法从资源 hibernate.hbm.xml 解析映射文档。为什么我会得到它?
【发布时间】:2013-06-06 07:53:12
【问题描述】:

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

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>

我不知道为什么会得到它。以下是 hibernate 映射文件:

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

下面是pojo package里面的类(映射类)

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;
    }

}

我用这个命令创建了一个名为b_files的表:

create table b_files(files_uploaded mediumblob, serial_number integer);

注意:我猜是映射文件中名为“file”的属性有问题。可以吗 ?因为我在我的 netbeans IDE 中没有得到“文件”作为提示。所以我猜这可能是问题所在。

【问题讨论】:

标签: java hibernate jakarta-ee hibernate-mapping pojo


【解决方案1】:

你在错误的地方关闭课程。 idproperty 应该在 &lt;/class&gt; 之前,而不是在其原始行中有快捷方式的关闭类。

【讨论】:

    猜你喜欢
    • 2013-05-13
    • 1970-01-01
    • 2016-01-23
    • 1970-01-01
    • 1970-01-01
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多