Bug #73406 import.sql in V 5.1.29 works, but not in 5.1.31
Submitted: 27 Jul 2014 4:34 Modified: 29 Aug 2014 18:33
Reporter: Tony Herstell Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.31 OS:Any
Assigned to: Jess Balint CPU Architecture:Any

[27 Jul 2014 4:34] Tony Herstell
Description:
Add a file into your project called import.sql.

Hibernate (JPA) "sees" the file and then "runs" the contained script during server runup if hbm2ddl.auto=create-drop

typically you can add :
  insert into xxx (id, xxx, xxxx) values (cccc, ddddd, rrrrr);

As Id is honoured then you can build relationships which is both awesome for pre-loading data with relationships which in turn is great for demoing/testing.

For 5.1.31:

BUG1:
The annotations (spring):
   @Column(name="xyz")
   private String xxx; 
is not honoured, so you have to use xxx (in fact the DB is created with xxx)!

BUG2:
The annotations (spring):
   @Id
   @GeneratedValue
   @Column(name="id")
   private Long id; 
The id setting in the import.sql is not honoured for, for example:
   insert into xxx (id, xxx, xxxx) values (1, ddddd, rrrrr);
The id of 1 is ignored and the item gets inserted with teh DB just using the "next" free id.

How to repeat:
Just run the server up.

Suggested fix:
Revert back to 5.1.29
[27 Jul 2014 5:13] Tony Herstell
It also seems that the column xxxYyyy
gets turned into xxx_yyyy
[27 Jul 2014 5:49] Tony Herstell
Sigh; its all quite confusing.
As the drop in create-drop doesn't work either then you find the id's can be reused (or course).
[28 Jul 2014 22:28] Mark Matthews
Other than it works with an older version of the JDBC driver, there's nothing directly in the JDBC driver itself that should've/could've broken this. Have you filed a hibernate bug? (there's nothing in the JDBC specification/implementation that supports the "import.sql" functionality. Something Hibernate is doing, is interacting badly with the JDBC driver).
[14 Aug 2014 17:38] Jess Balint
Hi Tony,
Thanks for your bug report. Can you please submit a self-contained program that will allow reproducing this behavior? Alternatively, I can look at the output from the general query logs if you can capture them using both the 5.1.29 and 5.1.31 drivers.
Thanks.
[14 Aug 2014 23:30] Tony Herstell
If there was a problem it mat have only affected the Spring version.

I am now using mysql-connector-java-5.1.32 on a few nice JEE project and no problems.

Feel free to close this... I will re-open if I have to go back to some legacy spring stuff and I hit it again.

Thx for your support.

:)
[29 Aug 2014 18:33] Jess Balint
Thanks Tony. Please report back if you can reproduce the issue.