Günay Gültekin
Günay Gültekin

Reputation: 4801

Hibernate "Table not found" error on runtime

I have created database successfully with no error and also I added dummy data after creation. Next, I try to get data from database however I have seen an error on console. It tries to create table which was created before.No need to recreate :/ I have searched internet and couldnt find anything related this.

I use MYSQL db, hibernate 4. These 3 classes (Material,MaterialProjectBrief,MaterialProjectImage) dont have any onetomany,manytoone annotations. I have other tables the same structure, they are working well (doing CRUD). I use annotations only I added mapping classed to hibernate.cfg.xml.

(Sorry for writing quickly because I have to leave the office now.

Here is the MaterialProjectImage class.

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class MaterialProjectImage implements Serializable {

    private static final long serialVersionUID = 3886003470849765887L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Integer id;

    @Column(name="LINK")    
    private String link;

    @Column(name="TITLE")
    private String title;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

}

Here is the log.

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000261: Table found: PORTAL.material

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000037: Columns: [id, aboutus, about, sıtemap, vısıon, worklocatıon, mıssıon, customers, rad, goal]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000108: Foreign keys: []

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000126: Indexes: [prımary]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000261: Table found: PORTAL.materialprojectbrief

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000037: Columns: [id, tıtle, shortbrıef, ıconlınk]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000108: Foreign keys: []

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000126: Indexes: [prımary]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata

INFO: HHH000262: Table not found: MaterialProjectImage

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000261: Table found: PORTAL.person

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000037: Columns: [id, username, ınfo, ımgpath, name, role, password]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000108: Foreign keys: []

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000126: Indexes: [prımary]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000261: Table found: PORTAL.project

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000037: Columns: [id, faq, tıtle, url, ınstallatıon]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000108: Foreign keys: []

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000126: Indexes: [prımary]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000261: Table found: PORTAL.projectwebview

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000037: Columns: [id, ıntro, ımglınk, project_id, type]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000108: Foreign keys: [fk_9qlhqdt00j5a5hknep10wu44c]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000126: Indexes: [fk_9qlhqdt00j5a5hknep10wu44c, prımary]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000261: Table found: PORTAL.project_document

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000037: Columns: [document_id, project_id]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000108: Foreign keys: [fk_6gwm4ft0jihnaprel3uem1or6, fk_ctnt2crdturw4k3xc5w4r5571]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.TableMetadata

INFO: HHH000126: Indexes: [fk_6gwm4ft0jihnaprel3uem1or6, uk_6gwm4ft0jihnaprel3uem1or6, fk_ctnt2crdturw4k3xc5w4r5571]

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata

INFO: HHH000262: Table not found: MaterialProjectImage

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

ERROR: HHH000388: Unsuccessful: create table MaterialProjectImage (id integer not null auto_increment, LINK varchar(255), TITLE varchar(255), primary key (id))

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

ERROR: Table 'materialprojectimage' already exists

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000232: Schema update complete

Upvotes: 0

Views: 19942

Answers (2)

Günay Gültekin
Günay Gültekin

Reputation: 4801

I have fixed the problem by adding @Table(name="material") annotation under the @Entity annotation according to here . Before doing this, I changed the lower_case_table_names however the problem still continued. Then I have realized to add tab annotation. Thanks.

Upvotes: 1

mohr_michael_a
mohr_michael_a

Reputation: 204

I suspect it is case sensitivity. As per the MySQL documentation:

How table and database names are stored on disk and used in MySQL is affected by the lower_case_table_names system variable, which you can set when starting mysqld. lower_case_table_names can take the values shown in the following table. On Unix, the default value of lower_case_table_names is 0. On Windows the default value is 1. On Mac OS X, the default value is 2.

Value Meaning 0 Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement. Name comparisons are case sensitive. You should not set this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or Mac OS X). If you force this variable to 0 with --lower-case-table-names=0 on a case-insensitive file system and access MyISAM tablenames using different lettercases, index corruption may result. 1 Table names are stored in lowercase on disk and name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases. 2 Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This works only on file systems that are not case sensitive! InnoDB table names are stored in lowercase, as for lower_case_table_names=1.

http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

Looking at your error logs it seems highly likely:

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata

INFO: HHH000262: Table not found: MaterialProjectImage

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

ERROR: HHH000388: Unsuccessful: create table MaterialProjectImage (id integer not null auto_increment, LINK varchar(255), TITLE varchar(255), primary key (id))

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

ERROR: Table 'materialprojectimage' already exists

22.Kas.2013 20:17:05 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000232: Schema update complete

Upvotes: 2

Related Questions