From c1415b4b8f01d0c3f091f0e7373a00ac6fc9e16b Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Sun, 22 May 2011 20:23:29 +0800 Subject: [PATCH] HHH-6113 re-fact and more tests --- .../xml/mocker/AnnotationMocker.java | 2 +- .../mocker/DefaultConfigurationHelper.java | 2 +- .../xml/mocker/EntityMappingsMocker.java | 21 ++++++++++++------- .../annotations/xml/mocker/IndexBuilder.java | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/AnnotationMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/AnnotationMocker.java index 309acdfeed..4be7b035bd 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/AnnotationMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/AnnotationMocker.java @@ -65,7 +65,7 @@ abstract class AnnotationMocker extends AbstractMocker { } protected boolean isDefaultCascadePersist() { - return defaults.isCascadePersist(); + return defaults.isCascadePersist()!=null && defaults.isCascadePersist(); } //@JoinTable diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/DefaultConfigurationHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/DefaultConfigurationHelper.java index 5345235bb4..ea03bb7897 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/DefaultConfigurationHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/DefaultConfigurationHelper.java @@ -95,7 +95,7 @@ class DefaultConfigurationHelper { if ( hasSchemaOrCatalogDefined( defaults ) ) { applyDefaultSchemaAndCatalog( annotationsMap, defaults ); } - if ( defaults.isCascadePersist() ) { + if ( defaults.isCascadePersist()!=null && defaults.isCascadePersist() ) { applyDefaultCascadePersist( annotationsMap ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/EntityMappingsMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/EntityMappingsMocker.java index 9eff57fd22..fad33ad681 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/EntityMappingsMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/EntityMappingsMocker.java @@ -165,8 +165,8 @@ public class EntityMappingsMocker { private String packageName; private String schema; private String catalog; - private boolean metadataComplete; - private boolean cascadePersist; + private Boolean metadataComplete; + private Boolean cascadePersist; public XMLAccessType getAccess() { return access; @@ -200,19 +200,19 @@ public class EntityMappingsMocker { this.schema = schema; } - public boolean isMetadataComplete() { + public Boolean isMetadataComplete() { return metadataComplete; } - void setMetadataComplete(boolean metadataComplete) { + void setMetadataComplete(Boolean metadataComplete) { this.metadataComplete = metadataComplete; } - public boolean isCascadePersist() { + public Boolean isCascadePersist() { return cascadePersist; } - void setCascadePersist(boolean cascadePersist) { + void setCascadePersist(Boolean cascadePersist) { this.cascadePersist = cascadePersist; } @@ -230,8 +230,13 @@ public class EntityMappingsMocker { if ( globalDefault.getCatalog() != null ) { catalog = globalDefault.getCatalog(); } - metadataComplete = globalDefault.isMetadataComplete(); - cascadePersist = globalDefault.isCascadePersist(); + if ( globalDefault.isCascadePersist() != null ) { + cascadePersist = globalDefault.isCascadePersist(); + } + if ( globalDefault.isMetadataComplete() != null ) { + metadataComplete = globalDefault.isMetadataComplete(); + } + } } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/IndexBuilder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/IndexBuilder.java index 2b4a4e9765..516c9e1fec 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/IndexBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/mocker/IndexBuilder.java @@ -184,10 +184,10 @@ public class IndexBuilder { // annotations classes overrided by xml if ( indexedClassInfoAnnotationsMap.containsKey( name ) ) { Map> tmp = getIndexedAnnotations( name ); - DefaultConfigurationHelper.INSTANCE.applyDefaults( tmp, defaults ); mergeAnnotationMap( tmp, map ); } - + DefaultConfigurationHelper.INSTANCE.applyDefaults( map, defaults ); + mergeAnnotationMap( map, annotations ); }