////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////


== hibernate



=== Purpose


The `hibernate` plugin configures the Hibernate implementation of link:{guidePath}GORM.html[GORM].


=== Examples


An example domain class:

[source,groovy]
----
class Book {
    String title
    Date releaseDate
    Author author
}
----


=== Description


Refer to the section on link:{guidePath}GORM.html[GORM] in the Grails user guide which details how to create Grails domain classes.

Configured Spring Beans:

* `dialectDetector` - An instance of link:{apiFromRef}org/grails/orm/hibernate/support/HibernateDialectDetectorFactoryBean.html[HibernateDialectDetectorFactoryBean] that attempts to automatically detect the Hibernate https://docs.hibernate.org/orm/5.6/javadocs/org/hibernate/dialect/Dialect.html[Dialect] which is used to communicate with the database.
* `hibernateProperties` - A `Map` of Hibernate properties passed to the `SessionFactory`
* `sessionFactory` - An instance of the Hibernate https://docs.hibernate.org/orm/5.6/javadocs/org/hibernate/SessionFactory.html[SessionFactory] class (Hibernate 7 users: https://docs.hibernate.org/orm/7.0/javadocs/org/hibernate/SessionFactory.html[SessionFactory])
* `transactionManager` - An instance of link:{apiFromRef}org/grails/orm/hibernate/support/hibernate5/HibernateTransactionManager.html[HibernateTransactionManager] from `grails-data-hibernate5-spring-orm` (Hibernate 7 users: link:{apiFromRef}org/grails/orm/hibernate/support/hibernate7/HibernateTransactionManager.html[HibernateTransactionManager] from `grails-data-hibernate7-spring-orm`). Spring Framework 7 removed the original `org.springframework.orm.hibernate5.HibernateTransactionManager`; Grails vendors the equivalent class for each supported Hibernate version.
* `persistenceInterceptor` - An instance of link:{apiFromRef}org/grails/plugin/hibernate/support/HibernatePersistenceContextInterceptor.html[HibernatePersistenceContextInterceptor] that abstracts away how persistence is used from the controller/view layer so that Grails can be used without GORM.
* `openSessionInViewInterceptor` - An instance of link:{apiFromRef}org/grails/datastore/mapping/web/support/OpenSessionInViewInterceptor.html[GrailsOpenSessionInViewFilter] that deals with Grails' https://docs.hibernate.org/orm/5.6/javadocs/org/hibernate/Session.html[Session] management (Hibernate 7 users: https://docs.hibernate.org/orm/7.0/javadocs/org/hibernate/Session.html[Session]).
