Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced subqueries content section from Gorm grails doc 2.5.0 content has been added to latest GORM documentation #358

Merged
merged 4 commits into from
Aug 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/en/guide/GORM/querying/whereQueries.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
23 changes: 23 additions & 0 deletions src/en/ref/Command Line/create-hibernate-cfg-xml.gdoc
Original file line number Diff line number Diff line change
@@ -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 <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}
grails create-hibernate-cfg-xml
{code}

Fired Events:

* CreatedFile - When the file is created