Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

While trying to write a text file to the database, I get the following exception :

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

as soon as I click the html submit button :

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

I don't know the reason for why am I getting it. Following is the hibernate mapping file :

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

Following is the class inside the pojo package (The mapping class) :

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

}

I used the this command to make a table named b_files :

create table b_files(files_uploaded mediumblob, serial_number integer);

Note : What I guess, is a problem with a property named 'file' in the mapping file. Is that Okay ? Because I do not get 'file' as a hint in my netbeans IDE. So I guess that it may the problem.

share|improve this question
    
and you are certain the mapping file is correctly named, in the correct directory, and has correct permissions? –  Andrew Lazarus Jun 6 '13 at 7:58
    
@AndrewLazarus yeah.tinypic.com/view.php?pic=ftdi0m&s=5 –  Suhail Gupta Jun 6 '13 at 8:06
add comment

1 Answer

up vote 0 down vote accepted

You are closing class in the wrong place. id and the property should precede a </class>, not close class with shortcut in its original line.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.