[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-886) hbm2ddl generating too long index on MySQL

Britt Park (JIRA) noreply at atlassian.com
Tue Aug 28 23:46:23 EDT 2007


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

Britt Park commented on HHH-886:
--------------------------------

I've searched the forums and found nothing relevant. The right solution, methinks, is to extend mapping syntax to allow explicit setting of index prefix lengths even for implicit indexes such as primary keys.  It's inconvenient, but easy enough to work around by hand editing generated ddl. I suggest that this either be reopened or a new enhancement request filed.


> hbm2ddl generating too long index on MySQL
> ------------------------------------------
>
>                 Key: HHH-886
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-886
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.0.5
>         Environment: MySQL 4.1.11-standard, MyISAMI, table with default charset utf8
>            Reporter: Oleg Marchuk
>
> SchemaExport log:
> alter table CountryLocal drop foreign key FK610C39952D58FB2F;
> drop table if exists CountryLocal;
> drop table if exists schedule;
> create table CountryLocal (
>     id varchar(255) not null,
>     name varchar(255) not null,
>     lang varchar(255) not null,
>     primary key (id, lang)
> );
> 17:19:59,997 ERROR SchemaExport:167 - Unsuccessful: create table CountryLocal (id varchar(255) not null, name varchar(255) not null, lang varchar(255) not null, primary key (id, lang))
> 17:20:00,003 ERROR SchemaExport:168 - Syntax error or access violation message from server: "Specified key was too long; max key length is 1000 bytes"
> create table schedule (
>     id varchar(255) not null,
>     primary key (id)
> );
> alter table CountryLocal 
>     add index FK610C39952D58FB2F (id), 
>     add constraint FK610C39952D58FB2F 
>     foreign key (id) 
>     references schedule (id);
> 17:20:00,014 ERROR SchemaExport:167 - Unsuccessful: alter table CountryLocal add index FK610C39952D58FB2F (id), add constraint FK610C39952D58FB2F foreign key (id) references schedule (id)
> 17:20:00,015 ERROR SchemaExport:168 - Base table or view not found message from server: "Table 'test_oleg.CountryLocal' doesn't exist"
> Mapping:
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping package="com.softzonenet">
> 	<class name="Test" table="schedule" lazy="false">
> 		<id name="id" type="string">
> 			<generator class="assigned" />
> 		</id>
> 		<map name="names" lazy="false" table="CountryLocal"
> 			cascade="delete">
> 			<key column="id" not-null="true" />
> 			<map-key type="string" column="lang" />
> 			<element type="string" column="name" not-null="true" />
> 		</map>
> 	</class>
> </hibernate-mapping>
> Class:
> package com.softzonenet;
> public class Test  {
>     
>     private String id = null;
>     
>     Test() {
>         
>     }
>     public String getId() {
>         return id;
>     }
>     public void setId(String id) {
>         this.id = id;
>     }
> }

-- 
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