|
16 | 16 |
|
17 | 17 | import grails.util.GrailsNameUtils; |
18 | 18 | import groovy.lang.GroovyObject; |
19 | | - |
20 | | -import java.beans.PropertyDescriptor; |
21 | | -import java.lang.reflect.Modifier; |
22 | | -import java.util.ArrayList; |
23 | | -import java.util.Collection; |
24 | | -import java.util.Collections; |
25 | | -import java.util.HashMap; |
26 | | -import java.util.HashSet; |
27 | | -import java.util.LinkedHashMap; |
28 | | -import java.util.List; |
29 | | -import java.util.Map; |
30 | | -import java.util.Set; |
31 | | - |
32 | 19 | import org.apache.commons.lang.ClassUtils; |
33 | 20 | import org.apache.commons.lang.StringUtils; |
34 | 21 | import org.codehaus.groovy.grails.exceptions.GrailsDomainException; |
35 | 22 | import org.codehaus.groovy.grails.exceptions.InvalidPropertyException; |
36 | 23 | import org.springframework.validation.Validator; |
37 | 24 |
|
| 25 | +import java.beans.PropertyDescriptor; |
| 26 | +import java.lang.reflect.Modifier; |
| 27 | +import java.util.*; |
| 28 | + |
38 | 29 | /** |
39 | 30 | * @author Graeme Rocher |
40 | 31 | */ |
@@ -248,20 +239,22 @@ private void establishRelationships() { |
248 | 239 | DefaultGrailsDomainClassProperty currentProp = (DefaultGrailsDomainClassProperty) o; |
249 | 240 | if (!currentProp.isPersistent()) continue; |
250 | 241 |
|
251 | | - Class<?> currentPropType = currentProp.getType(); |
| 242 | + Class currentPropType = currentProp.getType(); |
252 | 243 | // establish if the property is a one-to-many |
253 | 244 | // if it is a Set and there are relationships defined |
254 | 245 | // and it is defined as persistent |
255 | | - if (Collection.class.isAssignableFrom(currentPropType) || Map.class.isAssignableFrom(currentPropType)) { |
256 | | - establishRelationshipForCollection(currentProp); |
257 | | - } |
258 | | - // otherwise if the type is a domain class establish relationship |
259 | | - else if (DomainClassArtefactHandler.isDomainClass(currentPropType) && |
260 | | - currentProp.isPersistent()) { |
261 | | - establishDomainClassRelationship(currentProp); |
262 | | - } |
263 | | - else if (embedded.contains(currentProp.getName())) { |
264 | | - establishDomainClassRelationship(currentProp); |
| 246 | + if(currentPropType != null) { |
| 247 | + if (Collection.class.isAssignableFrom(currentPropType) || Map.class.isAssignableFrom(currentPropType)) { |
| 248 | + establishRelationshipForCollection(currentProp); |
| 249 | + } |
| 250 | + // otherwise if the type is a domain class establish relationship |
| 251 | + else if (DomainClassArtefactHandler.isDomainClass(currentPropType) && |
| 252 | + currentProp.isPersistent()) { |
| 253 | + establishDomainClassRelationship(currentProp); |
| 254 | + } |
| 255 | + else if (embedded.contains(currentProp.getName())) { |
| 256 | + establishDomainClassRelationship(currentProp); |
| 257 | + } |
265 | 258 | } |
266 | 259 | } |
267 | 260 | } |
|
0 commit comments