biz.c24.io.api
Class C24NamingStrategy

java.lang.Object
  extended by org.hibernate.cfg.DefaultNamingStrategy
      extended by biz.c24.io.api.C24NamingStrategy
All Implemented Interfaces:
Serializable, org.hibernate.cfg.NamingStrategy

public class C24NamingStrategy
extends org.hibernate.cfg.DefaultNamingStrategy

The pupose of this class is to add back ticks(`) to column names specified in the Hibernate mappings. This was added to prevent invalid SQL being created when database reserved words are being used as column names. NOTE: You can't run both SQL and HQL/Hibernate persistance using the same C24NamingStrategy. NOTE: Please ensure that the Hibernate & required 3rd party libraries added to your classpath (hibernate3.jar etc.). For more information about the Hibernate please visit: http://www.hibernate.org/

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.hibernate.cfg.DefaultNamingStrategy
INSTANCE
 
Constructor Summary
C24NamingStrategy(boolean isSQLQuery)
          Creates the NamingStrategy that adds back ticks(`) to column names when you are using HQL or normal Hibernate persistance.
 
Method Summary
 String columnName(String columnName)
          Adds back ticks(`) to the column name
 String tableName(String tableName)
          Adds back ticks(`) to the table name
 
Methods inherited from class org.hibernate.cfg.DefaultNamingStrategy
classToTableName, collectionTableName, foreignKeyColumnName, joinKeyColumnName, logicalCollectionColumnName, logicalCollectionTableName, logicalColumnName, propertyToColumnName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

C24NamingStrategy

public C24NamingStrategy(boolean isSQLQuery)
Creates the NamingStrategy that adds back ticks(`) to column names when you are using HQL or normal Hibernate persistance.

Parameters:
isSQLQuery - If this is true, the back ticks(`) will not be added. Usually the case when native SQL is used to select the data from the database.
Method Detail

tableName

public String tableName(String tableName)
Adds back ticks(`) to the table name

Specified by:
tableName in interface org.hibernate.cfg.NamingStrategy
Overrides:
tableName in class org.hibernate.cfg.DefaultNamingStrategy
Parameters:
tableName - The original table name specified in the mapping file
Returns:
the modified table name

columnName

public String columnName(String columnName)
Adds back ticks(`) to the column name

Specified by:
columnName in interface org.hibernate.cfg.NamingStrategy
Overrides:
columnName in class org.hibernate.cfg.DefaultNamingStrategy
Parameters:
columnName - The original column name specified in the mapping file
Returns:
the modified column name


C24 Technologies © 2002-2012: All Rights Reserved.