Hi,
I'm trying this mapping in MySQL which gives an error message when I run SchemaExportTask:
<property
name="url"
type="string"
update="true"
insert="true"
access="property"
column="URL"
length="1024"
not-null="true"
unique="true"
/>
[schemaexport] (hbm2ddl.SchemaExport 154 ) Unsuccessful:
create table LINK_STATS (
ID INTEGER NOT NULL AUTO_INCREMENT,
URL TEXT not null unique,
NB_VISITS INTEGER not null,
primary key (ID))
[schemaexport] (hbm2ddl.SchemaExport 155 ) General error, message from server: "
BLOB column 'URL' used in key specification without a key length"
When I set the length of the column to 255, I don't get an error (since MySQL uses the varchar type for this).
Also, when I allow nulls and duplicate values, it works too, but then I don't have an index on the column.
I tried @hibernate.column to add an index, but have the same problem here.
According to
http://dev.mysql.com/doc/mysql/en/CREATE_TABLE.html, I need to indicate an index prefix by using something like
CREATE TABLE test (url BLOB, INDEX(url(10)));
Is there any way I can indicate this in my Hibernate mappings (preferably XDoclet)?
Thanks,
Pieter Coucke
Hibernate 2.1.4
Mysql 4.0.18-nt