Thought inc.

The Dynamic O/R Mapping Company

features overview
> pure pojo - ejb3
> magic mapper
> high performance
> product tours
> o/r mapping
> querying solutions
> cocobase is free
> eclipse, spring
> technical spec's
> whitepapers

  tech support

querying solutions  

CocoBase® Offers The Amazing Ability To Query From An Object View And/Or A Relational View Of Data Covering The Full Spectrum Of Querying Requirements

The comprehensive CocoBase® Querying Solution includes four different querying systems;

  • EJBQL "Pure Object-Centric Querying Syntax"

  • High level CocoBase® Query API that looks very similar to SQL

  • Low level CocoBase® Query API

  • Standard CocoBase® Query by Example which queries instances instead of object models.

These four systems cover the breadth of required querying options needed for building enterprise-level corporate applications. The developer can choose to query data across the spectrum from an object view to a relational view depending on which method best fits the applications' requirements.

The CocoBase Query layer is built on the “Dynamic Object to Relational Mapping” architecture of CocoBase®. This extends for the developer all the benefits of CocoBase®, making for a querying system that decouples the application object from a particular database structure or particular SQL syntax, which allows data objects to be easily generated, maintained and reused.

The CocoBase® querying layer can be used with EJB-QL, a standards-based, object oriented syntax as defined in the EJB 2.0/3.0 specification. It can also be used at an API level with the CBQuery Builder which looks and works almost exactly like SQL. The developer has the choice to use either declarative-type querying with EJB-QL or procedural-type querying using the CBQuery Builder API to implement Dynamic Universal Querying™ in their Java applications.

The highlight is combining the simplicity of EJB-QL with the dynamic nature of the CocoBase® O/R Mapping layer. It results in unlimited querying for the user without the time-consuming work of pre-coded and pre-compiled SQL statements or custom finders.

With the multitude of Object Query Languages that generally only work with one component architecture, THOUGHT Inc.® felt it was important to choose a single query syntax that was powerful enough to issue meaningful queries and simple enough that most developers could easily learn to use it. EJB-QL fits these requirements very well and the CocoBase® implementation uses the syntax for any type of Java persistence and not just Enterprise Java Beans (EJB).

Highlighted Benefits:

  • Powerful and Easy to Use Querying system for issuing Meaningful Queries.

  • One Querying system for use with PURE POJO™, CMP & BMP Entity Beans, Session Beans, JSPs, Dynamic Transparent Persistence and Stand-Alone Java persistence.

  • Provides Unlimited Querying (based on the mapped data) to Application Users without all the work of pre-coded / pre-compiled SQL statements or custom finders.

  • Query system is architected to provide powerful queries with a rapid response time.

  • No changes to the Query are needed when changes are made to the database.

  • Further increases security of data in the database by limiting access to only the data represented in the map.

  • Two Ways To Express a Query:

    1) Declarative-type, standards-based Querying using the EJB-QL Syntax as specified in EJB 2.0,

    2) Procedural-API type Querying using the CocoBase® CBQuery Builder API, looks almost exactly like SQL, and is based on an “Abstract Schema (i.e. maps).”


EJBQL 3.0 Improvements

CocoBase EJBQL provides the amazing ability to query subsets of complex data.  This, for example, means that developers can query multi-field projections which allows portions of an object (and multiple objects) to be queried into a single result set object. EJB-QL grouping (i.e. group by/having) features are also supported.

Previously EJBQL was restricted to retrieving an entire object or one column of data. The new EJBQL 3.0 specification allows developers to create projections, which is a list of arbitrary columns from one or more objects in the database. It is a powerful method for querying reporting functions which can produce subsets of objects, etc. This makes it unnecessary to retrieve an entire large object when only a partial list of fields needs to be represented. Retrieving and presenting data is now possible without the extra overhead of retrieving the entire complex object or object model. This provides a much simpler and useful method for querying complex object model data which also increases application performance at the same time.

Additional querying enhancements

One of these new enhancements is for the low level CocoBase Query APIs which gives better support for custom and advanced 'subquery' syntax that is dynamically generated by the developer through custom SQL constructed by them.

Also, the ability to issue a block query for a specific range of values without requiring scrollable cursors to remain open meets the needs of users working with large data sets. The block query extracts a page of information that is within the whole large set of information and then closes the statement thus reducing throughput to the database. In other words, the block query or "Page Oriented Queries" gets the information or data without leaving an open resource to the database helping to protect overall performance.

The block query also includes the ability to specify the 'truncation' of a result set while issuing block/range queries which further increases performance and reduces overhead on databases that do not support SQL ROWNUM filtering. This has to do with telling the database to limit how many records internally it will construct into an object, so it will look at record 100 and add in the next 50 records for total of 50 records. This gives the developer the ability to further define and control the database thus restricting the number of objects retrieved to not more than needed which greatly increases efficiency and performance.