ORM settings

The following settings can be set in the ormsettings struct that ColdFusion uses to configure ORM. All these settings are optional. If you specify the value of any ORM setting to true or yes, then the setting is enabled, otherwise it is disabled.

Property Name Default Description
autogenmap true Specifies whether ColdFusion should automatically generate mapping for the persistent CFCs. If autogenmap=false, mapping should be provided in the form of .HBMXML files.
automanageSession Added in ColdFusion 9.0.1 true

Lets you specify if ColdFusion must manage Hibernate session automatically.

  • If enabled: ColdFusion manages the session completely. That is, it decides when to flush the session, when to clear the session, and when to close the session.
  • If disabled: The application is responsible for managing flushing, clearing, or closing of the session. The only exception is (in the case of transaction), when the transaction commits, the application flushes the session.
    ColdFusion closes the ORM session at the end of request irrespective of this flag being enabled or disabled.
cacheconfig   Specifies the location of the configuration file that should be used by the secondary cache provider.This setting is used only when secondarycacheenabled=true.See Secondary level cache in Caching for details.
cacheprovider ehcache

Specifies the cache provider that should be used by ORM as secondary cache. The values can be:

  • Ehcache
  • ConcurrentHashMap

Fully qualified name of the class for any other cache provider.This setting is used only when secondarycacheenabled=true. See Secondary level cache in Caching for details.

catalog   Specifies the default Catalog that should be used by ORM.
cfclocation   Specifies the directory (or array of directories) that should be used by ColdFusion to search for persistent CFCs to generate the mapping. If cfclocation is set, ColdFusion looks at only the paths specified in it. If it is not set, ColdFusion looks at the application directory, its sub-directories, and its mapped directories to search for persistent CFCs.
datasource   Specifies the data source that should be used by ORM. If it is not specified here, then the data source specified for the application is picked up. Use the following convention to specify a datasource name: this.datasource="<datasource_name>";
dbcreate none

ColdFusion ORM can automatically create the tables for your application in the database when ORM is initialized for the application. This can be enabled by using dbcreate in ormsettings. dbCreate takes the following values:

  • update: Setting this value creates the table if it does not exist or update the table if it exists.
  • dropcreate: Setting this value drops the table if it exists and then creates it.
  • none (default): Setting this value does not change anything in the database schema.
dialect  

Specifies the dialect. ColdFusion supports the following dialects:

  • DB2
  • DB2AS400
  • DB2OS390
  • Derby
  • PostgreSQL
  • MySQL
  • MySQLwithInnoDB
  • MySQLwithMyISAM
  • Oracle8i
  • Oracle9i
  • Oracle10g
  • Sybase
  • SybaseAnywhere
  • MicrosoftSQLServer
  • Informix
    Apart from these dialects, you can specify custom dialects by using the fully qualified class name.

    Note: For Microsoft Access, dialect cannot be detected automatically. Use Microsoft SQL Server as the dialect for it.

eventHandling false Specifies whether ORM Event callbacks should be given. See Event Handling in CFC for details.
flushatrequestend true Specifies whether ormflush should be called automatically at request end. If flushatrequestend is false, ormflush is not called automatically at request end. See ORM session management.
logSQL
false Specifies whether the SQL queries that are executed by ORM will be logged. If LogSQL=true, the SQL queries are logged to the console.
namingstrategy   Defines database standard and naming convention. See Naming strategy.
ormconfig   The Hibernate configuration file. This file contains various configuration parameters like, dialect, cache settings, and mapping files that are required for the application. The settings defined in the ormsettings override the settings defined in the Hibernate Configuration XML file.The connection information in the Hibernate Configuration XML file is however ignored because ColdFusion uses its own connection pool.You will need to use this only when you need to use a hibernate setting that is not available using ormsetting.
savemapping false Specifies whether the generated Hibernate mapping file has to be saved to disc. If you set the value to true, the Hibernate mapping XML file is saved with the filename "CFC name".hbmxml in the same directory as the CFC. If any value of savemapping is specified in CFC, it will override the value specified in the ormsetting.
schema   Specifies the default Schema that should be used by ORM.
secondarycacheenabled false Specifies whether secondary caching should be enabled. See Use secondary cache in Caching for details.
skipCFCWithError Added in ColdFusion 9.0.1 false Lets you specify if ColdFusion must skip the CFCs that have errors. If set to true, ColdFusion ignores the CFCs that have errors.
sqlscript   Path to the SQL script file that gets executed after ORM is initialized. This applies if dbcreate is set to dropcreate. This must be the absolute file path or the path relative to the application.The SQL script file lets you populate the tables before the application is accessed.
useDBForMapping true Specifies whether the database has to be inspected to identify the missing information required to generate the Hibernate mapping. The database is inspected to get the column data type, primary key and foreign key information.

Sample Application.cfc

<cfset this.ormenabled = "true">
<cfset this.ormsettings={datasource="cfartgallery", logsql="true"}>

Dapatkan bantuan lebih cepat dan lebih mudah

Pengguna baru?