[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3243) VARBINARY primary key with mysql doesn't function

Marc Ewert (JIRA) noreply at atlassian.com
Thu May 29 09:01:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30276 ] 

Marc Ewert commented on HHH-3243:
---------------------------------

The fix in PrimaryKey is not possible, because mysql allows tinyblob for primary keys, but not for foreign ones. 

This leads to the conclusion that the actual bug lies in MySQLDialect. It shouldn't map to tinyblob, but to varbinary for short VARBINARY columns. We fixed our problem by subclassing the MySQLDialect and executing in our constructor the following code:

registerColumnType(Types.VARBINARY, 255, "varbinary($l)");

Now everything is fine with our UUID primary (and foreign) keys. It should be considered to be fixed in the official MySQLDialect.

> VARBINARY primary key with mysql doesn't function
> -------------------------------------------------
>
>                 Key: HHH-3243
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3243
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.1
>         Environment: MySQL-5.0.51a, hibernate-3.2.1.ga
>            Reporter: Marc Ewert
>
> We have a 16-byte UUID type, which should be persisted in a VARBINARY (tinyblob) in a mysql database. But the primary key statement is invalid for mysql:
> ERROR 11:34:13 [main] (SchemaExport.java:create:274) -
> Unsuccessful:
> create table T_GRI_USER (C_ID tinyblob not null, C_ATTRIBUTES
> text, C_VERSION integer, C_PASSWORD varchar(255), C_VISIBILITIES 
> blob, C_STATE integer not null, C_LOGIN varchar(255) not null 
> unique, C_EMAIL varchar(255), primary key (C_ID)) 
> ERROR 11:34:13 [main] (SchemaExport.java:create:275) - BLOB/TEXT
> column 'C_ID' used in key specification without a key length
> The statement should end with ... primary key (C_ID({length})). This has to be done in the class PrimaryKey, which forms this part of the statement without involving the Dialect.
> The MySQLDialect has also a little bug, it doesn't write the length while defining the tinyblob column. But unfortunately this doesn't solve the SQL-Error. Unfortunately because the dialect is much better patchable for us as the PrimaryKey class deep in hibernate is...

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list