Skip to content

Commit

Permalink
GRAILS-2761 added script to create hibernate.cfg.xml files
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith committed May 18, 2010
1 parent 26751fb commit 283b65d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/guide/15. Grails and Hibernate.gdoc
@@ -1,11 +1,9 @@
If [GORM (Grails Object Relational Mapping)|guide:GORM] is not flexible enough for your liking you can alternatively map your domain class using Hibernate. To do this create a @hibernate.cfg.xml@ file in the @grails-app/conf/hibernate@ directory of your project and the corresponding HBM mapping xml files for your domain classes.
If [GORM|guide:GORM] (Grails Object Relational Mapping) is not flexible enough for your liking you can alternatively write some or all of your domain classes in Java or re-use an existing domain model that has been mapped using Hibernate. To do this create a @hibernate.cfg.xml@ file in the @grails-app/conf/hibernate@ directory of your project and add the corresponding HBM mapping xml files for your domain classes. You can do this manually or by running the [create-hibernate-cfg-xml|commandLine] script.

{note}
For more info on how to do this read the [documentation on mapping|http://www.hibernate.org/] on the Hibernate Website
For more info on how to do this read the [documentation on mapping|http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html] at the Hibernate Website
{note}

This will allow you to map Grails domain classes onto a wider range of legacy systems and be more flexible in the creation of your database schema.
This will allow you to map Grails domain classes onto a wider range of legacy systems and have more flexibility in the creation of your database schema.

Grails also allows you to write your domain model in Java or re-use an existing domain model that has been mapped using Hibernate. All you have to do is place the necessary @hibernate.cfg.xml@ file and corresponding mappings files in the @grails-app/conf/hibernate@ directory.

Additionally, the good news is you will still be able to call all of the dynamic persistent and query methods allowed in [GORM|guide:GORM]!
Additionally, you will still be able to call all of the dynamic persistent and query methods allowed in [GORM|guide:GORM]!
2 changes: 1 addition & 1 deletion src/guide/15.1 Mapping with Hibernate Annotations.gdoc
@@ -1,6 +1,6 @@
Grails also supports creating domain classes mapped with Hibernate's Java 5.0 Annotations support.

Now to create an annotated class we simply create a new Java class in @src/java@ and use the annotations defined as part of the EJB 3.0 spec (for more info on this see the [Hibernate Annotations Docs|http://annotations.hibernate.org/]):
To create an annotated domain class, create a new class in @src/java@ and use the annotations defined as part of the EJB 3.0 spec (for more info on this see the [Hibernate Annotations Docs|http://annotations.hibernate.org/]):

{code:java}
package com.books;
Expand Down
24 changes: 24 additions & 0 deletions src/ref/Command Line/create-hibernate-cfg-xml.gdoc
@@ -0,0 +1,24 @@
h1. create-hibernate-cfg-xml

h2. Purpose

The @create-hibernate-cfg-xml@ command will create a hibernate.cfg.xml file for custom Hibernate mappings.

h2. Examples

bc.
grails create-hibernate-cfg-xml

h2. Description

Creates a @hibernate.cfg.xml@ file in the @grails-app/conf/hibernate@ directory. You can add @<mapping>@ elements there to reference annotated Java domain classes, classes mapped by hbm.xml files, or hbm.xml files containing @<database-object>@ elements defining custom DDL that's not supported by GORM.

Usage:
{code:java}
grails create-hibernate-cfg-xml
{code}

Fired Events:

* @CreatedFile@ - When the file is created

0 comments on commit 283b65d

Please sign in to comment.