Skip to content

Commit 3044488

Browse files
Merge branch 'master' of github.com:grails/grails-core
2 parents e68ae96 + fc8e775 commit 3044488

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1463
-1443
lines changed

src/java/org/codehaus/groovy/grails/commons/DefaultGrailsDomainClassProperty.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,25 +539,39 @@ public ComponentDomainClass(Class<?> type) {
539539
PropertyDescriptor[] descriptors = getPropertyDescriptors();
540540

541541
List tmp = getPropertyValue(GrailsDomainClassProperty.TRANSIENT, List.class);
542-
if (tmp!=null) transients = tmp;
543-
properties = createDomainClassProperties(this,descriptors);
542+
if (tmp != null) transients = tmp;
543+
properties = createDomainClassProperties(descriptors);
544544
constraints = GrailsDomainConfigurationUtil.evaluateConstraints(getClazz(), properties);
545545
DomainClassGrailsPlugin.registerConstraintsProperty(getMetaClass(), this);
546546
}
547547

548-
private GrailsDomainClassProperty[] createDomainClassProperties(
549-
@SuppressWarnings("hiding") ComponentDomainClass type, PropertyDescriptor[] descriptors) {
548+
private GrailsDomainClassProperty[] createDomainClassProperties(PropertyDescriptor[] descriptors) {
550549

551550
List<DefaultGrailsDomainClassProperty> props = new ArrayList<DefaultGrailsDomainClassProperty>();
551+
Collection<String> embeddedNames = getEmbeddedList();
552552
for (int i = 0; i < descriptors.length; i++) {
553553
PropertyDescriptor descriptor = descriptors[i];
554554
if (isPersistentProperty(descriptor)) {
555-
props.add(new DefaultGrailsDomainClassProperty(type,descriptor));
555+
DefaultGrailsDomainClassProperty property = new DefaultGrailsDomainClassProperty(
556+
this, descriptor);
557+
props.add(property);
558+
if (embeddedNames.contains(property.getName())) {
559+
property.setEmbedded(true);
560+
}
556561
}
557562
}
558563
return props.toArray(new GrailsDomainClassProperty[props.size()]);
559564
}
560565

566+
@SuppressWarnings("unchecked")
567+
private Collection<String> getEmbeddedList() {
568+
Object potentialList = GrailsClassUtils.getStaticPropertyValue(getClazz(), "embedded");
569+
if (potentialList instanceof Collection) {
570+
return (Collection<String>)potentialList;
571+
}
572+
return Collections.emptyList();
573+
}
574+
561575
private boolean isPersistentProperty(PropertyDescriptor descriptor) {
562576
String propertyName = descriptor.getName();
563577
return GrailsDomainConfigurationUtil.isNotConfigurational(descriptor) && !transients.contains(propertyName);

src/java/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsDomainBinder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ private static void bindDependentKeyValue(GrailsDomainClassProperty property, De
743743
GrailsDomainClass refDomainClass = property.getDomainClass();
744744
final Mapping mapping = getMapping(refDomainClass.getClazz());
745745
if ((shouldCollectionBindWithJoinColumn(property) && hasCompositeIdentifier(mapping)) ||
746-
(hasCompositeIdentifier(mapping) && property.isManyToMany())) {
746+
(hasCompositeIdentifier(mapping) && property.isManyToMany())) {
747747
CompositeIdentity ci = (CompositeIdentity) mapping.getIdentity();
748748
bindCompositeIdentifierToManyToOne(property, key, ci, refDomainClass, EMPTY_PATH);
749749
}
@@ -1663,7 +1663,7 @@ else if (!"ordinal".equalsIgnoreCase(enumType)) {
16631663
Column column = new Column();
16641664

16651665
if (property.getDomainClass().isRoot()) {
1666-
column.setNullable(property.isOptional());
1666+
column.setNullable(property.isOptional());
16671667
} else {
16681668
Mapping mapping = getMapping(property.getDomainClass());
16691669
if(mapping == null || mapping.getTablePerHierarchy()) {
@@ -1795,6 +1795,10 @@ else if (currentGrailsProp.isManyToOne()) {
17951795
bindManyToOne(currentGrailsProp, (ManyToOne) value, path, mappings);
17961796
}
17971797
}
1798+
else if (currentGrailsProp.isEmbedded()) {
1799+
value = new Component(persistentClass);
1800+
bindComponent((Component) value, currentGrailsProp, true, mappings);
1801+
}
17981802
else {
17991803
if (LOG.isDebugEnabled())
18001804
LOG.debug("[GrailsDomainBinder] Binding property [" + currentGrailsProp.getName() + "] as SimpleValue");

0 commit comments

Comments
 (0)