From 10196c95e05cab7a2f1b93e85b0a37c3ba4773b5 Mon Sep 17 00:00:00 2001 From: Carlus Henry Date: Thu, 17 Feb 2011 20:32:22 -0500 Subject: [PATCH] will now work even if the table does not have a primary key. While working at a customer site, we found that when reverse engineering, we were not able to reverse engineer some tables. Turns out those tables did not have a primary key. This little modification alleviates the issue. --- src/groovy/grails/plugin/reveng/GrailsEntityPOJOClass.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/groovy/grails/plugin/reveng/GrailsEntityPOJOClass.groovy b/src/groovy/grails/plugin/reveng/GrailsEntityPOJOClass.groovy index 03fc186..2c89859 100644 --- a/src/groovy/grails/plugin/reveng/GrailsEntityPOJOClass.groovy +++ b/src/groovy/grails/plugin/reveng/GrailsEntityPOJOClass.groovy @@ -311,7 +311,7 @@ class GrailsEntityPOJOClass extends EntityPOJOClass { } clazz.table.uniqueKeyIterator.each { UniqueKey key -> - if (key.columnSpan == 1 || key.name == clazz.table.primaryKey.name) return + if (key.columnSpan == 1 || key.name == clazz.table.primaryKey?.name) return if (key.columns[-1] == column) { def otherNames = key.columns[0..-2].collect { "\"$it.name\"" } values.unique = '[' + otherNames.reverse().join(', ') + ']'