Skip to main content

Introduction to Caché Objects

This manual describes the various aspects of Caché objects. You may also find the Caché Web Applications Tutorial to be a useful introduction to the topic.

Caché object technologies give application developers the means to easily create high performance, object-based, database applications.

The features of Caché objects include:

  • A powerful object model that includes inheritance, properties, methods, collections, relationships, user-defined data types, and streams.

  • A flexible object persistence mechanism that allows objects to be stored within the native Caché database as well as external relational databases.

  • Control over the database aspects of persistent classes including indices, constraints, and referential integrity.

  • An easy-to-use transaction and concurrency model that includes the ability to load objects by navigation—simply referring to an object can “swizzle” it into memory from the database.

  • Automatic integration with Caché SQL via the Caché unified data architecture.

  • Interoperability with Java, C++, and ActiveX.

  • Automatic XML support.

  • A powerful, multi-user object development environment: Studio.

You can use Caché objects in many ways including:

  • To define the database and/or business components of a transaction processing application.

  • To create a web-based user interface using Caché Server Pages.

  • To define object-based stored procedures that are callable from ODBC or JDBC.

  • To provide object/relational access to legacy applications.

Caché Objects Architecture

Caché object technology contains the following major components:

  • The class dictionary — A repository of class definitions (often known as metadata), each of which describes a specific class. This repository is stored within a Caché database. The class dictionary is also used by the Caché SQL engine and is responsible for maintaining synchronized object and relational access to Caché data.

  • The class compiler — A set of programs that convert class definitions into executable code.

  • The object runtime system — A set of features built into the Caché virtual machine that support object operations (such as object instantiation, method invocation, and polymorphism) within a running program.

  • The Caché class library — A set of prebuilt classes that come with every Caché installation. This includes classes that are used to provide behaviors for user-defined classes (such as persistence or data types) as well as classes that are intended for direct use within applications (such as email classes).

  • The various language bindings — A combination of code generators and runtime components that provide external access to Caché objects. These bindings include the Caché Java binding, the Caché ActiveX binding, and the Caché C++ binding.

  • The various gateways — Server-side components that give Caché objects access to external systems. These gateways include the Caché SQL Gateway and the Caché Activate ActiveX Gateway.

Class Definitions and the Class Dictionary

Every class has a definition that specifies what members (properties, methods, and so on) it contains as well as class-wide characteristics (such as superclasses). These definitions are contained within the class dictionary, which is itself stored within the Caché database.

Creating Class Definitions

You can create class definitions in many ways:

  • Using Studio. The primary means of working with Caché class definitions is with the Studio Development Environment.

  • Using XML. Class definitions have an external, XML-based representation. Typically this format is used for storing class definitions externally (such as in source control systems), deploying applications, or simply for sharing code. You can also create new class definitions programmatically by simply generating the appropriate XML class definition file and loading it into a Caché system.

  • Using an API. Caché includes a set of class definition classes that provide object access to the class dictionary. You can use these to observe, modify, and create class definitions.

  • Using SQL DDL. Any relational tables defined by DDL statements are automatically converted to equivalent class definitions and placed within the class dictionary.

The Class Dictionary

Every Caché namespace contains its own class dictionary which defines the available classes for that namespace. There is a special “CACHELIB” database, installed as part of Caché, that contains the definitions and executable code for the classes of the Caché class library. These classes are referred to as system classes and all are part of packages whose names start with a “%” character, such as %Library.PersistentOpens in a new tab (the names of members of the %Library package can be abbreviated, so that %StringOpens in a new tab is an abbreviation for %Library.StringOpens in a new tab).

Every Caché namespace is automatically configured so that its class dictionary, in addition to containing its own classes, has access to the system class definitions and code within the CACHELIB database. By this mechanism, all namespaces can make direct use of the classes in the Caché class library.

The class dictionary contains two distinct types of data:

  • Definition data — The actual class definitions that users create.

  • Compilation data — Data generated as a result of compiling class definitions is also stored. This data includes the results of inheritance resolution; that is, it lists all the defined and inherited members for a given class. The class compiler uses this to make other compilation more efficient; applications can also use it (via the appropriate interface) to get runtime information about class members.

The class dictionary stores its data in a set of globals (persistent arrays) whose names start with ^odd. The structure of these arrays may change with new versions of Caché, so applications should never directly observe or modify these structures.

The Caché Class Library

The Caché class library contains a set of prebuilt classes. It is automatically installed with every Caché system within the CACHELIB database. You can view the contents of the Caché class library using the online class documentation system provided with Caché.

The Caché class library contains a number of packages, each of which contains a family of classes. Some of these are internal and Caché objects uses them as part of its implementation. Other classes provide features that are designed for use in applications.

The main packages within the Caché class library include:

Caché Class Library Packages
Package Description
%Activate Classes used by the Caché Activate ActiveX gateway. See Using the Caché ActiveX Gateway.
%Compiler Internal classes used by the class compiler.
%CSP Classes used by Caché Server Pages. See Using Caché Server Pages (CSP).
%csr A set of generated internal classes that implement the standard CSP rules.
%Library The core set of Caché “behavioral” classes (such as %PersistentOpens in a new tab). Also includes the various data types, collections, and stream classes.
%Net A set of classes providing various Internet-related features (such as email, HTTP requests, and so on). See Using Caché Internet Utilities.
%Projection A set of projection classes that generate client-side code for user classes. See the chapter “Class Projections.”
%SOAP Classes you can use to create web services and web clients within Caché. See Creating Web Services and Web Clients in Caché.
%SQL Internal classes used by Caché SQL.
%Studio Internal classes used by Studio.
%SYSTEM The various system API classes accessible via the $System special variable.
%XML Classes used to provide XML and SAX support within Caché. For information, see Projecting Objects to XML and Using Caché XML Tools.

For a comprehensive list of options, see the table of contents of the InterSystems Programming Tools Index.

Development Tools

Caché includes a number of tools for developing object-based applications. In addition, it is quite easy to use Caché with other development environments.

Studio

Studio is an integrated, visual development environment for creating Caché class definitions. See Using Studio for more details.

SQL-Based Development

It is possible to develop Caché applications using SQL-based tools, since Caché automatically creates a class definition from any relational tables defined using SQL DDL statements. This approach does not exploit the full power of objects because you are limited by what DDL can express; however, it is useful for migrating legacy applications.

XML-Based Development

It is possible to develop class definitions as XML documents and load them into Caché. You can do this using either the Caché-specific XML format for class definitions or you can use an XML schema representation.

User Interface Development and Client Connectivity

Caché object technology supports connections with the Caché user-interface development tools as well as its connectivity tools for interoperating with other systems. For a comprehensive list of options, see the table of contents of the InterSystems Programming Tools Index.

FeedbackOpens in a new tab