cborm
Install
v2.x
v2.x
  • Introduction
  • Intro
    • Release History
      • What's New With 2.5.0
      • What's New With 2.4.0
      • What's New With 2.3.0
      • What's New With 2.2.1
      • What's New With 2.2.0
      • What's New With 2.1.0
      • What's New With 2.0.0
    • About This Book
    • Author
  • Getting Started
    • Overview
    • Installation
    • Basic Crud - Services
    • Basic Crud - ActiveEntity
  • Base ORM Service
    • Overview
    • Service Properties
    • Concrete Services
    • Automatic Java Types
    • Dynamic Finders- Counters
      • Method Signatures
      • Method Expressions
      • Query Options
    • Service Methods
      • Criteria Queries
        • getRestrictions
        • newCriteria
      • Creation - Population
        • new
        • populate
        • populateFromJSON
        • populateFromQuery
        • populateFromXML
      • Counters
        • count
        • countWhere
        • exists
      • Deleting Entities
        • delete
        • deleteAll
        • deleteByID
        • deleteByQuery
        • deleteWhere
      • Entity Convenience Methods
        • getDirtyPropertyNames
        • getEntityGivenName
        • getEntityMetadata
        • getKey
        • getKeyValue
        • getPropertyNames
        • getTableName
        • isDirty
        • refresh
      • Finders
        • findit
        • findOrFail
        • findByExample
        • findWhere
        • findAll
        • findAllWhere
      • Getters
        • get
        • getOrFail
        • getAll
      • ORM Session
        • clear
        • evict
        • evictCollection
        • evictQueries
        • getSessionStatistics
        • isSessionDirty
        • merge
        • sessionContains
      • Querying
        • executeQuery
        • list
      • Saving Entities
        • save
        • saveAll
      • Utility Methods
        • autoCast
        • createService
        • idCast
        • nullValue
  • Virtual Services
    • Overview
    • Service Properties
    • Concrete Virtual Services
  • Active Record
    • Active Entity Overview
    • Constructor Properties
    • Usage
    • Validation
  • Criteria Queries
    • Criteria Builder
      • Getting Started
      • Restrictions
        • Value Casting
        • SQL Restrictions
      • Modifiers
      • Results
      • Associations
      • Projections & Aggregates
    • Detached Criteria Builder
      • Getting Started
      • Projections
      • Subqueries
      • DetachedSQLProjection()
      • Criterias
      • Associations
    • Help! I'm Not Getting the Result I expected!
  • Advanced Features
    • Mementifier
    • Automatic REST Crud
    • ORM Events
      • Custom Event Handler
    • Unique Property Validation
Powered by GitBook
On this page

Was this helpful?

Edit on Git
Export as PDF
  1. Criteria Queries

Detached Criteria Builder

PreviousProjections & AggregatesNextGetting Started

Last updated 5 years ago

Was this helpful?

Hibernate also supports the concept of detached criterias. They are most useful for join conditions, subselects, and to query outside the current session.

Some applications need to create criteria queries in "detached mode", where the Hibernate session is not available. Then you can execute the search in an arbitrary session.

To create an instance of Detached Criteria Builder, simply call the createSubcriteria() method on your existing criteria.

If you use ORM in your ColdBox apps, you are hopefully already taking full advantage of , ColdBox’s powerful, programmatic DSL builder for Hibernate Criteria queries (and if you’re not using it, you should!). With the new Detached Criteria Builder, you can expand the power and flexibility of your criteria queries with support for criteria and projection subqueries, all while using the same intuitive patterns of Criteria Builder. No fuss, just more flexibility and control for your criteria queries!

"Some applications need to create criteria queries in "detached mode", where the Hibernate session is not available. It also allows you to express subqueries." Hibernate Docs

For more information about Detached Criteria and Subqueries, check out the following Hibernate documentation:

  1. Hibernate Docs:

  2. Hibernate DetachedCriteria:

  3. Hibernate Subqueries:

INFO The best place to see all of the functionality of the Detached Criteria Builder is to check out the latest .

Criteria Builder
http://docs.jboss.org/hibernate/orm/3.5/reference/en/html/querycriteria.html#querycriteria-detachedqueries
http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/criterion/DetachedCriteria.html
http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/criterion/Subqueries.html
API Docs