views:

193

answers:

1

I am running a MySQL 5.1 server and Hibernate 3.5.1 / JPA2 for ORM. Everthing seems fine until I drop some tables manually. From then on, unit tests fail with Hibernate no longer creating certain tables. Changing the jdbc url from

url=jdbc:mysql://localhost:3306/dbjava?createDatabaseIfNotExist=true

to

url=jdbc:mysql://localhost:3306/dbjavanew?createDatabaseIfNotExist=true

solves the problem ... until I perform some table drops :-( Since I am going to use MySQL for production, this must not happen at all.

Dropping dbjava does not help too. Any suggestions?

--- ADDITIONAL INFO:

It's getting really weired. From mysql console:

mysql> use dbjava;
Database changed
mysql> show tables;
+---------------------+
| Tables_in_dbjava    |
+---------------------+
| aa                  |
| ba                  |
| da                  |
| ea                  |
| hibernate_sequences |
| ia                  |
| ka                  |
| la                  |
+---------------------+
8 rows in set (0.00 sec)
mysql> create table `cA` (id integer not null, comment varchar(255), name varchar(255), id_d integer, id_f integer, primary key (id)) ENGINE=InnoDB;
ERROR 1050 (42S01): Table 'ca' already exists

Uh? Why does Table 'ca' exist?!?!? Actually, it once existed ... since then, it was dropped, the whole db was dropped several times ... why does it still exist?

Even worse:

 mysql> drop table cA;
 mysql> ERROR 1051 (42S02): Unknown table 'ca'

Totally confused ...

However, I just realised something: my table names in hibernate use lower and upper case (camel case) notation. mysql responses lower case only. Would anybody confirm that mysql does not recognize case-sensitiveness in the year 2010 ?!?

+1  A: 

Which dialect are you using? Newer versions of Hibernate (can't remember exact numbers) have InnoDB dialect fix: instead of type=InnoDb it uses engine=InnoDb when creating tables -- which is the only legitimate syntax in MySQL 5.1. Just to remind, MySQL 5.0 accepted both type and engine keywords.

mindas
That was a good suggestion, however, it did not help. I added <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> to appcontext.xml entity manager and <property name="dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> to persistence context. However, please mind the additional information I will give within 5 mins by editing my original question
If Hibernate could create the tables the first time, I don't see how the dialect could be guilty.
Pascal Thivent