Hibernate3.0 automatically generates pojo and map reports table 'table _ name' doesn' t exist through Eclipse plug-in.

Source: Internet
Author: User
Tags sql error

I recently want to create a new project and use hibernate3.0 for persistence,
I downloaded hibernate-tools and used it to generate the pojo and map ing files. The source code is as follows:
Mysql5.0 database name used: hibernatetest

Table Structure:

Create Table 'cat '(
'Cat _ id' varchar (32) not null,
'Name' varchar (16) Character Set Latin1 not null default '',
'Sex' char (2) Character Set Latin1 default null,
'Weight' int (11) default null,
Primary Key ('cat _ id ')
) Engine = InnoDB default charset = gb2312

Cat. Java

Package com. First. pojo;

Import java. util .*;

Public class cat implements java. Io. serializable {

Private string catid;
Private string name;
Private string sex;
Private integer weight;

Public CAT (){
}

Public CAT (string catid ){
This. catid = catid;
}

Public String GETID (){
Return this. catid;
}

Public void setid (string catid ){
This. catid = catid;
}

Public String getname (){
Return this. Name;
}

Public void setname (string name ){
This. Name = Name;
}

Public String getsex (){
Return this. sex;
}

Public void setsex (string sex ){
This. Sex = sex;
}

Public integer getweight (){
Return this. weight;
}

Public void setweight (integer weight ){
This. Weight = weight;
}
}

Cat. HBM. xml

<? XML version = "1.0"?>
<! Doctype hibernate-mapping public "-// hibernate/hibernate mapping DTD 3.0 // en"
Http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd>
<Hibernate-mapping>
<! --
Auto-generated mapping file from
The hibernate.org has 2hbm Engine
-->
<Class name = "com. First. pojo. Cat" table = "cat" catalog = "hibernatetest">
<ID name = "ID" type = "string">
<Column name = "cat_id" length = "32"/>
<Generator class = "UUID. Hex"/>
</ID>
<Property name = "name" type = "string">
<Column name = "name" length = "16" not-null = "true"/>
</Property>
<Property name = "sex" type = "string">
<Column name = "sex" length = "2"/>
</Property>
<Property name = "weight" type = "integer">
<Column name = "weight"/>
</Property>
</Class>
</Hibernate-mapping>

Execution error:
SQL error: 1146, sqlstate: 42s02
1890 [main] Error util. jdbcexceptionreporter-base table or view not found, message from server: "Table 'hibernatetest. hibernatetest _ cat' doesn' t exist"

Table 'hibernatetest. hibernatetest _ cat'. If hibernatetest_cat's hibernatetest indicates the database, the previous hibernatetest. it indicates that the database is duplicated. Therefore, if the table cannot be found, a catalog = "hibernatetest" ing file does not know what to do, and the database name is deleted, it's normal, alas! I went there again for half a day, Dizzy !!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.