Search code examples
grailsreverse-engineeringcomposite-keycompound-key

Compound key reverse engineering grails pulgin issue


i have this table :

CREATE TABLE `documents_revisions` (
  `es_id` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `seq_head` int(10) unsigned NOT NULL,
  `member_id` int(10) unsigned NOT NULL,
  `file_id` varchar(512) COLLATE utf8_unicode_ci NOT NULL,
  `save_hash` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
  UNIQUE KEY `documents_rev_eis_idx` (`es_id`,`seq_head`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

When i apply reverse eng grails plugin grails db-reverse-engineer , i get this error :

Method public java.lang.String grails.plugin.reveng.GrailsEntityPOJOClass.renderConstraints() threw an exception when invoked on Entity: abdennour.DocumentsRevisions

However , there is no pb with the others Db tables . Indeed , Reverse engineering works fine with those tables.

Thus , i note that this plugin have a problem with compound key .

Please , Note that is a composite UNIQUE key it is not a composite PRIMARY key


Solution

  • This is a bug in the plugin - it assumes that all tables have a primary key and fails when the object representing that in the model is null. I released version 0.5.1 of the plugin with a fix for this.