Resin CMP Configuration
Resin 2.1

Reference Guide
EJB Reference Guide

EJBServer
JNDI
Entity Config
Relation Config
Session Config
Resin-EJB Config
SQL mapping
Transaction Config
Message Config
EJB-QL
xdoclet
Config Summary
Burlap
JMS
CORBA/IIOP
Index
Session Config
EJB Reference Guide
SQL mapping

abstract-sql-typeAn abstract SQL type to be used when automatically creating a table for the entity bean
cache-sizeDefines the size of the entity cache
cache-timeoutDefines how long a loaded bean will remain loaded
cmp-fieldDefines one of the bean's fields to be managed by Resin-CMP
data-sourceSpecifies the database JNDI name for the DataSource
field-nameSpecifies the field name for a cmp-field definition
methodConfiguration for a business method
query-functionAdds a new function to the EJB-QL language
query-loads-beanIf true, an ejbSelect or find query will load the beans in the query's select
read-onlyConfigures a bean as read-only
resin-ejbTop-level configuration for the Resin-specific configuration
resin-isolationConfigures the isolation level for a method
signatureSpeficies a function signature, i
sql-columnThe SQL column name for a field or relation
sql-typeThe SQL type to be used when automatically creating a table for the entity bean

Configuration

abstract-sql-type

An abstract SQL type to be used when automatically creating a table for the entity bean. Resin-CMP will use the abstract-sql-type and the database driver type to determine the actual type used to create the database table.

cache-size

Resin-CMP 1.0.5

Defines the size of the entity cache.

The default cache-size is 8192.

cache-timeout

Resin-CMP 1.0.5

Defines how long a loaded bean will remain loaded. As long as a cached CMP bean is loaded, it doesn't need to query the database, saving time and database load.

The default value is 5 seconds.

cmp-field

Defines one of the bean's fields to be managed by Resin-CMP. Since Resin-CMP will introspect the cmp-fields from the classes, the cmp-field is optional.

cmp-fields are either Java primitives or serializable types, i.e. values in a database table. Relations between beans are configured in the relations section.

ElementMeaning
field-namethe field name
sql-columnthe SQL column name
sql-typethe SQL type

The SQL name is generated automatically from the cmp-field (or the getter method.) The getter method getMyField corresponds to the cmp-field myField and the SQL column my_field. An EJB-QL query, always uses the cmp-field name, e.g. myField.

The cmp-field can specify the SQL column name using sql-column.

student.ejb
  <entity>
    <abstract-schema-name>students</abstract-schema-name>
    <sql-table>student_table</sql-table>
    ...
    <cmp-field>
      <field-name>id</field-name>
      <sql-column>student_id</sql-column>
    </cmp-field>
    <cmp-field>
      <field-name>name</field-name>
      <sql-column>user_name</sql-column>
    </cmp-field>
    ...
  </entity>

The above descriptor would expect the following schema:

student.sql
CREATE TABLE student_table (
  student_id INTEGER AUTO_INCREMENT,
  user_name VARCHAR(255),

  PRIMARY KEY(student_id)
);

data-source

Specifies the database JNDI name for the DataSource. If unspecified, it defaults to the value in EJBServer.

field-name

Specifies the field name for a cmp-field definition. The field-name is the bean name for the Java getter method. So the field-name for getFoo is foo.

method

Configuration for a business method. Each business method is specified by a <signature>. The signature syntax is the same as Java function syntax without the return type.

The arguments are optional and the method name can be "*". The best matching method will be used. Methods which match a method with specified args is better than a method with only a method name. And both are better than the default match.

Configure most methods as read-only
<method signature="*">
  <resin-isolation>read-only</resin-isolation>
</method>

<method signature="writeMethod(String)">
  <resin-isolation>database</resin-isolation>
</method>

method ::= signature, resin-isolation?

query-function

Adds a new function to the EJB-QL language. The query-function must specify the function signature in Java syntax. The following types are allowed: int, double, boolean, String, Date and any.

Adding MD5
<query-function>
  <signature>String MD5(String)</signature>
</query-function>

query-function ::= signature

query-loads-bean

If true, an ejbSelect or find query will load the beans in the query's select. If false, the query will only load the primary key and lazily load the bean when it's referenced.

Normally, setting this true will give better performance.

Default all querys to lazy load
<method>
  <signature>*</signature>
  <query-loads-bean>false</query-loads-bean>
</method>

Default: true by default.

read-only

Configures a bean as read-only. Read only entity bean values can be cached between calls. The cache time is configured with cache-time.

resin-ejb

Top-level configuration for the Resin-specific configuration.

resin-ejb ::= enterprise-beans

resin-isolation

Configures the isolation level for a method. Each method is classified with either read-only or database isolation. read-only methods only read database from the database. database methods read and write to the database.

By telling Resin which methods are read-only, Resin can effectively cache read values and reduce the database load.

For methods defined by EJB as write methods, Resin will ignore the read-only value. setXXX, create, and remove methods always have database or stronger isolation.

For methods defined by EJB as read methods, Resin will use read-only as a default.

Default: the default value is database

signature

Speficies a function signature, i.e. a method declaration, in Java syntax. In the case of <query-function>, <signature> specifies the name and types for a new EJB-QL function.

sql-column

The SQL column name for a field or relation. If is unspecified, it defaults to the field name. The value of sql-column is never used in the EJB queries. It's just used during SQL generation.

For relations where the target bean has a compound primary key, the sql-column can specify a references attribute to distinguish which part of the primary key to configure.

Specifying a cmp-field
<entity>
  <ejb-name>students</ejb-name>
  ...
  <cmp-field>
    <field-name>id</field-name>
    <sql-column>student_id</sql-column>
  </cmp-field>
</entity>

A pointer to a compound-key bean
<cmr-field>
  <cmr-field-name>child</cmr-field-name>
  <sql-column references='parent'>test_parent</sql-column>
  <sql-column references='name'>test_cname</sql-column>
</cmr-field>

sql-type

The SQL type to be used when automatically creating a table for the entity bean. The sql-type is the string that will be used in the CREATE TABLE.

Formal Definition

resin-ejb ::= enterprise-beans?, query-function*

enterprise-beans ::= entity*

entity ::= (ejb-name,
            sql-table?,
            cache-timeout?,
            cache-size?,
            data-source?,
            cmp-field*,
            method*)

cmp-field ::= (field-name,
               sql-column?,
               abstract-sql-type?,
               sql-type?)

sql-column ::= (text(column-name) |
                (references, id))

query-function ::= signature

method ::= signature,
           resin-isolation?
           query-loads-bean?


Session Config
EJB Reference Guide
SQL mapping
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.