6 Replies Latest reply on Sep 17, 2005 10:12 AM by Andrig Miller

    MySQL Catalog (or Schema) Name not being prepended in the EJ

    Andrig Miller Newbie

      I have been writting an EJB3 prototype using MySQL 4.1.xx, and I was getting a SQL parse error on the generated insert statement, causing my Order object's persist to fail. After experimenting using the MySQL query browser, I discovered that MySQL requires the catalog or schema name to be prepended to the table name even though you have connected specifically to that catalog in the connection URL. Therefore the following Hibernate (EJB3) generated SQL statement of:

      insert into Order (state, customerid, addressline1, addressline2, city, zipcode, zipplusfour) values (?, ?, ?, ?, ?, ?, ?)

      fails, and it needs to look like this:

      insert into prototype.Order (state, customerid, addressline1, addressline2, city, zipcode, zipplusfour) values (?, ?, ?, ?, ?, ?, ?)

      Now, the only way I could get the statement to look like this was to change the entities @Table tag from:

      @Table(name="Order)

      to:

      @Table(name="prototype.Order")

      Obviously, this ties the entity directly to the specific schema, making it un-portable to multiple database schema's or catalogs. This cannot be the proper way to fix this issue, even though it did work.

      Can anyone shed some light on what I am missing? There must be a property somewhere that I am not setting or not setting correctly.