I use reverse engine generated .java code and .hbm.xml file, the table name is “UploadedFile”, entity name in hbm.xml and in java code is “UploadedFile”, however when I try to insert one entry in to DB, it send out the sql “insert into testdb.dbo.uploaded_file (upload_file_file_name, upload_file_file_content) values (?, ?)”, and then I get the exception that “testdb.dbo.uploaded_file” is invalid.
The UploadedFile.hbm.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generated 2018-11-11 21:10:52 by Hibernate Tools 5.3.6.Final --><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="true" default-access="property" default-cascade="none" default-lazy="true">
<class catalog="TestDB" dynamic-insert="false" dynamic-update="false" mutable="true" name="com.yp.entity.UploadedFile" optimistic-lock="version" polymorphism="implicit" schema="dbo" select-before-update="false" table="UploadedFile">
<id name="uploadFileId" type="java.lang.Integer">
<column name="UploadFile_ID"/>
<generator class="identity"/>
</id>
<property generated="never" lazy="false" name="uploadFileFileName" optimistic-lock="true" type="string" unique="false">
<column length="20" name="UploadFile_FileName" not-null="true"/>
</property>
<property generated="never" lazy="false" name="uploadFileFileContent" optimistic-lock="true" type="binary" unique="false">
<column name="UploadFile_FileContent" not-null="true"/>
</property>
</class>
</hibernate-mapping>
public class UploadedFile implements java.io.Serializable {
private Integer uploadFileId;
private String uploadFileFileName;
private byte[] uploadFileFileContent;
public UploadedFile() {
}
//getter,setter
}
The database table:
create table UploadFile(
UploadFile_ID int identity primary key,
UploadFile_FileName varchar(20) not null,
UploadFile_FileContent varbinary(2048) not null,
);
Why the entity name in sql becomes “uploaded_file”?