Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 58133 invoked from network); 9 Jul 2005 00:09:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Jul 2005 00:09:39 -0000 Received: (qmail 78201 invoked by uid 500); 9 Jul 2005 00:09:38 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 78193 invoked by uid 500); 9 Jul 2005 00:09:38 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 78180 invoked by uid 99); 9 Jul 2005 00:09:38 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jul 2005 17:09:29 -0700 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 6E1B315 for ; Sat, 9 Jul 2005 02:09:26 +0200 (CEST) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Apache Wiki To: scm@geronimo.apache.org Date: Sat, 09 Jul 2005 00:09:26 -0000 Message-ID: <20050709000926.12578.96698@ajax.apache.org> Subject: [Geronimo Wiki] Update of "Working with Enterprise JavaBeans" by JacekLaskowski X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Dear Wiki user, You have subscribed to a wiki page or wiki category on "Geronimo Wiki" for change notification. The following page has been changed by JacekLaskowski: http://wiki.apache.org/geronimo/Working_with_Enterprise_JavaBeans The comment on the change is: Minor editorial changes ------------------------------------------------------------------------------ = About = + This page describes the OpenEJB-specific configurations required to deploy EJB onto Geronimo. - This page presents from a user perspective the OpenEJB specific configurations required to get EJB up and - running within Geronimo. = CMP Entity Beans = This section assumes that you: - * know how to deploy a JDBC data source in Geronimo; and - * know what is a GBean. + + * know how to deploy a JDBC data source in Geronimo - see [http://wiki.apache.org/geronimo/Deployment#head-21336a0a66d1920932fb37038c3a558f332948bd Database configuration] + * know what is a GBean - see [http://wiki.apache.org/geronimo/FrequentlyAskedQuestions#head-c831847749b8a4938088b431ee53c0def26d6c0a What on Earth is a GBean? Why are they different from MBeans?] + * are familiar with the deployment configuration schema - see openejb\modules\openejb-builder\src\schema in the OpenEJB repository == Database Configuration == The CMP engine gains access to the database used to store the entity beans via the connection factory - identified by the ''cmp-connection-factory element''. This latter is a "generic" element providing enough + identified by the '''' element. This latter is a "generic" element providing enough information to identify a JDBC data source already deployed or being deployed along with the CMP entity beans. - The following snippet illustrates a typical usage of the ''cmp-connection-factory element'', where the + The following snippet illustrates a typical usage of the '''' element, where the out-of-the-box connection factory, and hence database, is used. '''Snippet #1 – Defining a connection factory''' @@ -38, +39 @@ === CMP Fields === - An entity bean is mapped to a single table via the ''table-name'' element. Its persistent fields are + An entity bean is mapped to a single table via the '''' element. Its persistent fields are - mapped to the columns of this same table via the ''cmp-field-mapping'' elements. + mapped to the columns of this same table via the '''' elements. The following snippet illustrates the usage of both of these elements, where: + - * the entity bean ''BeanA'' is mapped to the table ''A''; and + * the entity bean ''BeanA'' is mapped to the table ''A'' + * its field ''field1'' is mapped to the column ''a1''. '''Snippet #2 – Mapping an entity bean to a table and its fields to some table columns''' @@ -60, +63 @@ The above configuration is the simplest one and should work in most cases as long as the data type conversion between the Java type of field1 and the SQL one of a1 can be carried out properly as per the JDBC specifications. - In all the other scenarii, for instance where ''field1'' is a ''byte[]'' and ''a1'' is a BLOB, two optional + In all the other cases, for instance where ''field1'' is a ''byte[]'' and ''a1'' is a BLOB, two optional elements may be used in conjunction to control explicitly the SQL type to use and how to perform the conversion between the type of ''field1'' and the one of ''a1''. These two optional elements are: - ''sql-type'', a SQL type identifier, which must be the name of a field declared by the ''java.sql.Types'' + '''', a SQL type identifier, which must be the name of a field declared by the ''java.sql.Types'' - class; and ''type-converter'', the full class name of a ''org.tranql.sql.Type''''''Converter'' implementation. + class; and '''', the full class name of a ''org.tranql.sql.Type''''''Converter'' implementation. The ''org.tranql.sql.Type''''''Converter'' type defines two contracts: ''convert''''''Java''''''To''''''SQL''''''Type()'' which is used to convert Java types to SQL types and ''convert''''''SQL''''''To''''''Java''''''Type()'' to realize the inverse operation. @@ -168, +171 @@ == Auto-Generated Primary Key == + Primary keys of entity beans can be auto-generated. This can save you the trouble of providing primary keys for entities in the create() call. This feature may also be used to deploy entity beans without a natural primary key, ''i.e.'' having a primary key class set to ''java.lang.Object''. The configuration of auto-generated primary key entity beans requires the configuration of a ''key-generator'' element for each affected EJB. - Primary keys of entity beans can be auto-generated. This can save you the trouble of providing primary keys for entities in the create() call. This feature may also used to deploy entity beans without - a natural primary key, ''i.e.'' having a primary key class set to ''java.lang.Object''. The configuration of auto-generated primary key entity beans requires the configuration - of a ''key-generator'' element for each affected EJB. The children of the key-generator element define the strategy to be used to auto-generate primary key instances. The provided strategies are: * ''auto-increment-table'': use table generated primary keys (auto-generated on a table other than the entity table); @@ -189, +190 @@ EJB_NAME 10 - + ... INSERT INTO SOME_OTHER_TABLE VALUES () java.lang.Integer - + ... SELECT MY_ORACLE_SEQ.NEXTVAL FROM DUAL java.lang.Integer - + ... geronimo.server:name=MyCustomGeneratorName java.lang.Integer - + }}} Note that Geronimo does not yet handle the case where the entity table itself has a primary key field that is automatically populated.