Paul Furbacher commented on Bug HHH-6005

I was just bitten by this bug while trying to adapt inherited code, and fortunately found the following StackOverflow thread: http://goo.gl/gHh8N. Here's the code:

@Entity
public class Address {
    @Id @GeneratedValue
    private Long id;
    @ElementCollection
    private List<String> lines;
    private String city;
    ...

Note the member variable, @ElementCollection private List<String> line*s*.

Hibernate hbm2ddl (schema generation in a JPA context) works with HSQL but not MySQL. I'm not manipulating the naming strategy in code or configuration, just to be clear. Here's the logging describing the error when targeting MySQL:

11:10:28.181 INFO java.sql.DatabaseMetaData - HHH000262: Table not found: Address_lines
11:10:28.208 ERROR o.h.tool.hbm2ddl.SchemaUpdate - HHH000388: Unsuccessful: create table Address_lines (Address_id bigint not null, lines varchar(255))
11:10:28.209 ERROR o.h.tool.hbm2ddl.SchemaUpdate - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lines varchar(255))' at line 1
11:10:28.213 ERROR o.h.tool.hbm2ddl.SchemaUpdate - HHH000388: Unsuccessful: alter table Address_lines add index FK1786B6D4A31CF299 (Address_id), add constraint FK1786B6D4A31CF299 foreign key (Address_id) references Address (id)
11:10:28.213 ERROR o.h.tool.hbm2ddl.SchemaUpdate - Table 'myschema.address_lines' doesn't exist

If I change the member variable name to "line" from "lines", the problem goes away when targeting MySQL. (For what it matters, I can change the name to "liness" and the problem goes away – the table name becomes "address_liness".)

Since "lines" does not create a problem generating the schema when targeting HSQL (2.2.8), but does when targeting MySQL (5.6.10, driver version: 5.1.23), I'm guessing this is a problem with coding in the respective dialect class.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira