Author: epbernard
Date: 2009-12-08 09:20:56 -0500 (Tue, 08 Dec 2009)
New Revision: 18159
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAMetadataProvider.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/XMLContext.java
core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java
Log:
HHH-4649 Properly bind Environment#GLOBALLY_QUOTED_IDENTIFIERS to orm.xml
<delimited-identifier/>
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
---
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java 2009-12-08
13:14:47 UTC (rev 18158)
+++
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java 2009-12-08
14:20:56 UTC (rev 18159)
@@ -288,6 +288,12 @@
//process default values first
if ( !isDefaultProcessed ) {
+ //use global delimiters if orm.xml declare it
+ final Object isDelimited = reflectionManager.getDefaults().get(
"delimited-identifier" );
+ if (isDelimited != null && isDelimited == Boolean.TRUE) {
+ getProperties().put( Environment.GLOBALLY_QUOTED_IDENTIFIERS, "true" );
+ }
+
AnnotationBinder.bindDefaults( createExtendedMappings() );
isDefaultProcessed = true;
}
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAMetadataProvider.java
===================================================================
---
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAMetadataProvider.java 2009-12-08
13:14:47 UTC (rev 18158)
+++
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAMetadataProvider.java 2009-12-08
14:20:56 UTC (rev 18159)
@@ -48,6 +48,8 @@
if ( defaults == null ) {
defaults = new HashMap<Object, Object>();
XMLContext.Default xmlDefaults = xmlContext.getDefault( null );
+
+ defaults.put( "delimited-identifier", xmlDefaults.getDelimitedIdentifier()
);
List<Class> entityListeners = new ArrayList<Class>();
for ( String className : xmlContext.getDefaultEntityListeners() ) {
try {
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/XMLContext.java
===================================================================
---
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/XMLContext.java 2009-12-08
13:14:47 UTC (rev 18158)
+++
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/XMLContext.java 2009-12-08
14:20:56 UTC (rev 18159)
@@ -73,6 +73,8 @@
globalDefaults.setAccess( unitElement != null ? unitElement.getTextTrim() : null );
unitElement = defaultElement.element( "cascade-persist" );
globalDefaults.setCascadePersist( unitElement != null ? Boolean.TRUE : null );
+ unitElement = defaultElement.element( "delimited-identifiers" );
+ globalDefaults.setDelimitedIdentifiers( unitElement != null ? Boolean.TRUE : null
);
defaultEntityListeners.addAll( addEntityListenerClasses( defaultElement, null,
addedClasses ) );
}
}
@@ -198,6 +200,7 @@
private String catalog;
private Boolean metadataComplete;
private Boolean cascadePersist;
+ private Boolean delimitedIdentifier;
public String getAccess() {
return access;
@@ -262,6 +265,7 @@
if ( globalDefault.getPackageName() != null ) packageName =
globalDefault.getPackageName();
if ( globalDefault.getSchema() != null ) schema = globalDefault.getSchema();
if ( globalDefault.getCatalog() != null ) catalog = globalDefault.getCatalog();
+ if ( globalDefault.getDelimitedIdentifier() != null ) delimitedIdentifier =
globalDefault.getDelimitedIdentifier();
if ( globalDefault.getMetadataComplete() != null ) {
metadataComplete = globalDefault.getMetadataComplete();
}
@@ -269,6 +273,14 @@
if ( globalDefault.getCascadePersist() != null ) cascadePersist =
globalDefault.getCascadePersist();
}
}
+
+ public void setDelimitedIdentifiers(Boolean delimitedIdentifier) {
+ this.delimitedIdentifier = delimitedIdentifier;
+ }
+
+ public Boolean getDelimitedIdentifier() {
+ return delimitedIdentifier;
+ }
}
public List<String> getDefaultEntityListeners() {
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java 2009-12-08 13:14:47
UTC (rev 18158)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java 2009-12-08 14:20:56
UTC (rev 18159)
@@ -2803,6 +2803,8 @@
final class ObjectNameNormalizerImpl extends ObjectNameNormalizer implements
Serializable {
public boolean isUseQuotedIdentifiersGlobally() {
+ //Do not cache this value as we lazily set it in Hibernate Annotation
(AnnotationConfiguration)
+ //TODO use a dedicated protected useQuotedIdentifier flag in Configuration (overriden
by AnnotationConfiguration)
String setting = (String) properties.get( Environment.GLOBALLY_QUOTED_IDENTIFIERS );
return setting != null && Boolean.valueOf( setting ).booleanValue();
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java 2009-12-08
13:14:47 UTC (rev 18158)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java 2009-12-08
14:20:56 UTC (rev 18159)
@@ -188,9 +188,6 @@
this.setProperty( Environment.DATASOURCE, metadata.getNonJtaDatasource() );
}
defineTransactionType( metadata.getTransactionType(), workingVars );
- if ( metadata.isUseQuotedIdentifiers() ) {
- this.setProperty( Environment.GLOBALLY_QUOTED_IDENTIFIERS, "true" );
- }
if ( metadata.getClasses().size() > 0 ) {
workingVars.put( HibernatePersistence.CLASS_NAMES, metadata.getClasses() );
}
Show replies by date