diff --git a/src/en/guide/GORM/querying/whereQueries.gdoc b/src/en/guide/GORM/querying/whereQueries.gdoc index 12c2b0464dc..9469e278154 100644 --- a/src/en/guide/GORM/querying/whereQueries.gdoc +++ b/src/en/guide/GORM/querying/whereQueries.gdoc @@ -90,6 +90,8 @@ def query = Person.where { } {code} + + h4. Query Composition Since the return value of the @where@ method is a [DetachedCriteria|guide:detachedCriteria] instance you can compose new queries from the original query: @@ -252,6 +254,56 @@ Person.where { {code} +h4. More Advanced Subqueries in GORM + +The support for subqueries has been extended. You can now use in with nested subqueries + +{code} +def results = Person.where { + firstName in where { age < 18 }.firstName +}.list() +{code} + +Criteria and where queries can be seamlessly mixed: + +{code} + def results = Person.withCriteria { + notIn "firstName", Person.where { age < 18 }.firstName + } +{code} + +Subqueries can be used with projections: + +{code} +def results = Person.where { + age > where { age > 18 }.avg('age') +} +{code} + +Correlated queries that span two domain classes can be used: +{code} + def employees = Employee.where { + region.continent in ['APAC', "EMEA"] + }.id() + def results = Sale.where { + employee in employees && total > 100000 + }.employee.list() +{code} + +And support for aliases (cross query references) using simple variable declarations has been added to where queries: +{code} +def query = Employee.where { + def em1 = Employee + exists Sale.where { + def s1 = Sale + def em2 = employee + return em2.id == em1.id + }.id() +} +def results = query.list() +{code} + + h4. Other Functions There are several functions available to you within the context of a query. These are summarized in the table below: diff --git a/src/en/ref/Command Line/create-hibernate-cfg-xml.gdoc b/src/en/ref/Command Line/create-hibernate-cfg-xml.gdoc new file mode 100644 index 00000000000..47622568b28 --- /dev/null +++ b/src/en/ref/Command Line/create-hibernate-cfg-xml.gdoc @@ -0,0 +1,23 @@ +h3. Purpose + +The create-hibernate-cfg-xml command will create a hibernate.cfg.xml file for custom Hibernate mappings. + +h3. Examples + +{code} +grails create-hibernate-cfg-xml +{code} + +h3. Description + +Creates a hibernate.cfg.xml file in the grails-app/conf/hibernate directory. You can add elements there to reference annotated Java domain classes, classes mapped by hbm.xml files, or hbm.xml files containing elements defining custom DDL that's not supported by GORM. + +Usage: + +{code} +grails create-hibernate-cfg-xml +{code} + +Fired Events: + +* CreatedFile - When the file is created \ No newline at end of file