org.hibernate.cfg
Class ObjectNameNormalizer

java.lang.Object
  extended by org.hibernate.cfg.ObjectNameNormalizer

public abstract class ObjectNameNormalizer
extends Object

Provides centralized normalization of how database object names are handled.


Nested Class Summary
static interface ObjectNameNormalizer.NamingStrategyHelper
          Helper contract for dealing with NamingStrategy in different situations.
 
Constructor Summary
ObjectNameNormalizer()
           
 
Method Summary
protected abstract  NamingStrategy getNamingStrategy()
          Get the current NamingStrategy.
protected abstract  boolean isUseQuotedIdentifiersGlobally()
          Retrieve whether the user requested that all database identifiers be quoted.
 String normalizeDatabaseIdentifier(String explicitName, ObjectNameNormalizer.NamingStrategyHelper helper)
          Performs the actual contract of normalizing a database name.
 String normalizeIdentifierQuoting(String identifier)
          Allow normalizing of just the quoting aspect of identifiers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectNameNormalizer

public ObjectNameNormalizer()
Method Detail

normalizeDatabaseIdentifier

public String normalizeDatabaseIdentifier(String explicitName,
                                          ObjectNameNormalizer.NamingStrategyHelper helper)
Performs the actual contract of normalizing a database name.

Parameters:
explicitName - The name the user explicitly gave for the database object.
helper - The NamingStrategy helper.
Returns:
The normalized identifier.

normalizeIdentifierQuoting

public String normalizeIdentifierQuoting(String identifier)
Allow normalizing of just the quoting aspect of identifiers. This is useful for schema and catalog in terms of initially making this public.

This implements the rules set forth in JPA 2 (section "2.13 Naming of Database Objects") which states that the double-quote (") is the character which should be used to denote a quoted identifier. Here, we handle recognizing that and converting it to the more elegant bactick (`) approach used in Hibernate.. Additionally we account for applying what JPA2 terms

Parameters:
identifier - The identifier to be quoting-normalized.
Returns:
The identifier accounting for any quoting that need be applied.

isUseQuotedIdentifiersGlobally

protected abstract boolean isUseQuotedIdentifiersGlobally()
Retrieve whether the user requested that all database identifiers be quoted.

Returns:
True if the user requested that all database identifiers be quoted, false otherwise.

getNamingStrategy

protected abstract NamingStrategy getNamingStrategy()
Get the current NamingStrategy.

Returns:
The current NamingStrategy.


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.