I'm trying to have SchemaExport generate my table structure in MySQL. It works as long as there are only one to one mappings but many to one or many to many will yield the following:
Code:
2004-01-25 09:57:48,390 INFO [net.sf.hibernate.cfg.Environment] - <Hibernate 2.1.1>
2004-01-25 09:57:48,406 INFO [net.sf.hibernate.cfg.Environment] - <loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, hibernate.jndi.class=com.sun.jndi.fscontext.RefFSContextFactory, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jndi.url=file:/, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.pool_size=1}>
2004-01-25 09:57:48,406 INFO [net.sf.hibernate.cfg.Environment] - <using java.io streams to persist binary types>
2004-01-25 09:57:48,421 INFO [net.sf.hibernate.cfg.Environment] - <using CGLIB reflection optimizer>
2004-01-25 09:57:48,437 INFO [net.sf.hibernate.cfg.Configuration] - <configuring from resource: /hibernate.cfg.xml>
2004-01-25 09:57:48,437 INFO [net.sf.hibernate.cfg.Configuration] - <Configuration resource: /hibernate.cfg.xml>
2004-01-25 09:57:49,078 INFO [net.sf.hibernate.cfg.Configuration] - <Mapping resource: com/triligon/addressbook/Person.hbm.xml>
2004-01-25 09:57:49,281 INFO [net.sf.hibernate.cfg.Binder] - <Mapping class: com.triligon.addressbook.Person -> Person>
2004-01-25 09:57:49,390 INFO [net.sf.hibernate.cfg.Binder] - <Mapping collection: com.triligon.addressbook.Person.categories -> HIB_CATEGORIES$TARGET_KEY_ATT_PEOPLE$SOURCE_KEY_ATT>
2004-01-25 09:57:49,468 INFO [net.sf.hibernate.cfg.Binder] - <Mapping subclass: com.triligon.addressbook.PersonImpl -> Person>
2004-01-25 09:57:49,468 INFO [net.sf.hibernate.cfg.Configuration] - <Mapping resource: com/triligon/addressbook/Address.hbm.xml>
2004-01-25 09:57:49,515 INFO [net.sf.hibernate.cfg.Binder] - <Mapping class: com.triligon.addressbook.Address -> Address>
2004-01-25 09:57:49,515 INFO [net.sf.hibernate.cfg.Binder] - <Mapping subclass: com.triligon.addressbook.AddressImpl -> Address>
2004-01-25 09:57:49,515 INFO [net.sf.hibernate.cfg.Configuration] - <Mapping resource: com/triligon/category/GlobalCategory.hbm.xml>
2004-01-25 09:57:49,578 INFO [net.sf.hibernate.cfg.Binder] - <Mapping class: com.triligon.category.GlobalCategory -> GlobalCategory>
2004-01-25 09:57:49,578 INFO [net.sf.hibernate.cfg.Binder] - <Mapping collection: com.triligon.category.GlobalCategory.people -> HIB_CATEGORIES$SOURCE_KEY_ATT_PEOPLE$TARGET_KEY_ATT>
2004-01-25 09:57:49,578 INFO [net.sf.hibernate.cfg.Binder] - <Mapping subclass: com.triligon.category.GlobalCategoryImpl -> GlobalCategory>
2004-01-25 09:57:49,578 INFO [net.sf.hibernate.cfg.Configuration] - <Configured SessionFactory: null>
2004-01-25 09:57:49,609 INFO [net.sf.hibernate.dialect.Dialect] - <Using dialect: net.sf.hibernate.dialect.MySQLDialect>
2004-01-25 09:57:49,609 INFO [net.sf.hibernate.cfg.Configuration] - <processing one-to-many association mappings>
2004-01-25 09:57:49,625 INFO [net.sf.hibernate.cfg.Configuration] - <processing one-to-one association property references>
2004-01-25 09:57:49,625 INFO [net.sf.hibernate.cfg.Configuration] - <processing foreign key constraints>
2004-01-25 09:57:49,703 INFO [net.sf.hibernate.cfg.Configuration] - <processing one-to-many association mappings>
2004-01-25 09:57:49,703 INFO [net.sf.hibernate.cfg.Configuration] - <processing one-to-one association property references>
2004-01-25 09:57:49,703 INFO [net.sf.hibernate.cfg.Configuration] - <processing foreign key constraints>
2004-01-25 09:57:49,718 INFO [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Running hbm2ddl schema export>
2004-01-25 09:57:49,718 INFO [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <exporting generated schema to database>
2004-01-25 09:57:49,718 INFO [net.sf.hibernate.connection.DriverManagerConnectionProvider] - <Using Hibernate built-in connection pool (not for production use!)>
2004-01-25 09:57:49,718 INFO [net.sf.hibernate.connection.DriverManagerConnectionProvider] - <Hibernate connection pool size: 1>
2004-01-25 09:57:49,734 INFO [net.sf.hibernate.connection.DriverManagerConnectionProvider] - <using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://10.2.2.2/test>
2004-01-25 09:57:49,734 INFO [net.sf.hibernate.connection.DriverManagerConnectionProvider] - <connection properties: {user=root, password=terror}>
2004-01-25 09:57:50,203 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Unsuccessful: create table HIB_CATEGORIES$TARGET_KEY_ATT_PEOPLE$SOURCE_KEY_ATT (PEOPLE$SOURCE_KEY_ATT VARCHAR(255) not null, CATEGORIES$TARGET_KEY_ATT VARCHAR(255) not null, primary key (PEOPLE$SOURCE_KEY_ATT, CATEGORIES$TARGET_KEY_ATT))>
2004-01-25 09:57:50,203 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Invalid argument value, message from server: "Specified key was too long. Max key length is 500">
2004-01-25 09:57:50,312 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Unsuccessful: create table HIB_CATEGORIES$SOURCE_KEY_ATT_PEOPLE$TARGET_KEY_ATT (CATEGORIES$SOURCE_KEY_ATT VARCHAR(255) not null, PEOPLE$TARGET_KEY_ATT VARCHAR(255) not null, primary key (CATEGORIES$SOURCE_KEY_ATT, PEOPLE$TARGET_KEY_ATT))>
2004-01-25 09:57:50,312 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Invalid argument value, message from server: "Specified key was too long. Max key length is 500">
2004-01-25 09:57:50,421 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Unsuccessful: alter table HIB_CATEGORIES$TARGET_KEY_ATT_PEOPLE$SOURCE_KEY_ATT add index (PEOPLE$SOURCE_KEY_ATT), add constraint FK709890502642CB12 foreign key (PEOPLE$SOURCE_KEY_ATT) references Person (personID)>
2004-01-25 09:57:50,421 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <General error, message from server: "Table 'test.HIB_CATEGORIES$TARGET_KEY_ATT_PEOPLE$SOURCE_KEY_ATT' doesn't exist">
2004-01-25 09:57:50,421 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Unsuccessful: alter table HIB_CATEGORIES$TARGET_KEY_ATT_PEOPLE$SOURCE_KEY_ATT add index (CATEGORIES$TARGET_KEY_ATT), add constraint FK70989050D46C75B foreign key (CATEGORIES$TARGET_KEY_ATT) references GlobalCategory (globalCategoryID)>
2004-01-25 09:57:50,421 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <General error, message from server: "Table 'test.HIB_CATEGORIES$TARGET_KEY_ATT_PEOPLE$SOURCE_KEY_ATT' doesn't exist">
2004-01-25 09:57:50,421 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Unsuccessful: alter table HIB_CATEGORIES$SOURCE_KEY_ATT_PEOPLE$TARGET_KEY_ATT add index (CATEGORIES$SOURCE_KEY_ATT), add constraint FK64342CD01AE693E5 foreign key (CATEGORIES$SOURCE_KEY_ATT) references GlobalCategory (globalCategoryID)>
2004-01-25 09:57:50,421 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <General error, message from server: "Table 'test.HIB_CATEGORIES$SOURCE_KEY_ATT_PEOPLE$TARGET_KEY_ATT' doesn't exist">
2004-01-25 09:57:50,421 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Unsuccessful: alter table HIB_CATEGORIES$SOURCE_KEY_ATT_PEOPLE$TARGET_KEY_ATT add index (PEOPLE$TARGET_KEY_ATT), add constraint FK64342CD018A2FE88 foreign key (PEOPLE$TARGET_KEY_ATT) references Person (personID)>
2004-01-25 09:57:50,421 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <General error, message from server: "Table 'test.HIB_CATEGORIES$SOURCE_KEY_ATT_PEOPLE$TARGET_KEY_ATT' doesn't exist">
2004-01-25 09:57:50,421 INFO [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <schema export complete>
2004-01-25 09:57:50,421 INFO [net.sf.hibernate.connection.DriverManagerConnectionProvider] - <cleaning up connection pool: jdbc:mysql://10.2.2.2/test>
Is this a bug or am I doing something wrong? The mapping files are generated from Java classes generated with AndroMDA which are then processed by xdoclet.